I need a PHP function to transform some data sets.
Input data is CSV format , output is txt. I have added some data sets to play with.
This is how I would like the data transformed:
Two consecutive lines from the CSV represent the start and finish of a process.
[url removed, login to view],8337,,,181976,
[url removed, login to view],8468,,,181976,
It is a start if second value is 8337.
It is a stop if second value is 8468.
The values are suppose to be always in sequence (a line with 8337 always followed by a line with 8468), if not it means corruption of data (see below).
I need this two lines to become one(from example above):
[ 'Session: 181976', new Date(2014,09,25,16,48,43), new Date(2014,09,25,16,53,52)],
So second last value from first line becomes 'Session: value' and then some work with the data stamp.
[url removed, login to view],8337,,,182001,
[url removed, login to view],8468,,,182001,
[ 'Session: 182001', new Date(2014,09,25,16,54,30), new Date(2014,09,25,16,58,13)],
Another example (now for more lines):
[url removed, login to view],8337,,,180226,
[url removed, login to view],8468,,,180226,
[url removed, login to view],8337,,,156780,
[url removed, login to view],8468,,,156780,
[ 'Session: 180226', new Date(2014,09,25,17,47,24), new Date(2014,09,25,17,56,15)],
[ 'Session: 156780', new Date(2014,09,25,17,56,51), new Date(2014,09,25,18,47,27)],
Some additional rules:
- if first line of the file starts with 8468, that line will be discarded.
- if last line of the file finishes with 8337, that line will be discarded.
- if a line with 8337, anywhere in the file, is followed by a line with 8337, the first line will be discarded from resulting data set.
Some of the lines in the file will not have a value for second to last, then it simple becomes 'Session: '.
I hope I managed to make sense, if not, ask away.
25 freelancer bu iş için ortalamada 152$ teklif veriyor
Hi, This is Gopal for STALLIONi, I am comfortable for the terms you described. Shall we discuss about the task? Please text me here when you ready to discuss about the task. Thanks
Hello, I am 4+ years of experienced developer and can do this csv reading and convert it to text file with the formatting the data into array and ready to start working on this. Thanks, Waiting for your reply.
This is an easy project for me. Just award me to start right now. One question: Will the last line of text file has a comma "," at the end or nothing? Thank you in advance.
I can do this fast and cheap. All i need is a good review so be confident I'll do my best. I've already done things like this. PM me for more details. Good luck