10-18-2010 09:18 AM
I've tried numerous searches but can't seem to find what I need to do. I need to read a file with two columns, the first column is the time of an event. I then need to calculate the time between each event (row). I know I need to use a for loop to read through the file but I cannot find any information on what the best way to calculate the time between each event so that I can get stastics like average time per cycle, time since last cycle etc.The only way I can think of is to read the file as a string and then parse the time but that doesn't seem like an efficient way of doing things.
example: data.csv
8:00 10
8:12 8
10:00 2
11:12 3
Solved! Go to Solution.
10-18-2010 10:18 AM
10-18-2010 12:36 PM
Gerd,
Thanks for the reply. I get what you mean by converting from string to numbers, makes sense. I tried your scan from string and I get a -32400 like number for the time in a double indicator. Is it incorrect or am I doing something wrong?
10-18-2010 01:03 PM
Use "%<%H:%M>t" as the format string instead. The capital T formats the time as an absolute time, which based on your format isn't what you're working with. The lowercase t will format it as a relative time stamp and you should be able to calculate your time between events.
Hope this helps,
Rob
10-18-2010 01:59 PM
I see the difference in time with the smaller t. Really my question is more of what exactly do I do with that number it pumps out? How do I subtract one reading from another to see the time between? Thanks for the help so far it has been great.
10-18-2010 09:18 PM - edited 10-18-2010 09:19 PM
On the numeric palette is the subtract function. That works quite well in subtracting one value from another.
10-19-2010 08:07 AM
Note that converted times are in seconds. Absolute times are seconds from midnight Jan 1, 1904.
10-19-2010 12:53 PM
Where is my staples easy button? I guess that was an obvious one I should have tried. Thanks again gentlemen you have been a big help.
10-20-2010 07:39 AM