I am trying to graph data from existing .log
files (or .txt
file, it doesn't matter).
The file is organised like this.
Unixepochtime value value.\n
Unixepochtime value value value value
The first line is different as it only has two values after the time, whereas all the following lines (200+ maybe) are exactly the same as the second line seen above.
However these last two values in the second line and following lines are not needed.
The output needs to be in a file or string in the following manner:
[unixepochtime, value], [unixepochtime, value]
Of course there will be one for every line though, so to make that clear, the string above would cover two lines of data.
For the second value in the file, it needs to have the same unixepochtime as was on its line, but be written in the format above in another string.
Can this work for files with an unknown amount of lines also? I'm using Flot
, if that helps. Can this code also work for files with only one value following the time please?
I commented it so I hope you can learn from it (what is the most important thing here!) Should work - although untested...