LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert timestamp from text file (hh:mm:ss) into seconds

How can I import a column of time stamps from a text file of the form hh:mm:ss and convert it into seconds using LabView? For example, 13:30:30 into 48630.

Also, using the "Read from Spreadsheet File VI" I can't seem to get the entire time stamp imported correctly. Only the value before the colon is read. For example, if the timestamp reads 13:30:30, only 13 is inputed into the array in LabView.

FYI I'm using LabView 7. Thanks!
0 Kudos
Message 1 of 7
(6,586 Views)
You should read it in as a string and then use string-to-number conversion to extract each portion of the time one by one.
0 Kudos
Message 2 of 7
(6,586 Views)
Thanks, but I'm running LabView 7.0 and it doesn't want to let me open a 7.1 file. I'll try what you suggested but I'm a LabView newbie. Any chance you can save as a 7.0 file? Thanks.
0 Kudos
Message 3 of 7
(6,586 Views)
Here's a LV 7 example. Just a Scan From String, a couple of Multiply functions and add the results. As far as your Read From Spreadsheet issue, by default, the function creates an array of SGLs. 13:30:30 is text and the functions needs to be modified to return an array of strings. There are instructions on the diagram on how to do this. When you've made the changes, save it as a new name and in a new location.
Message 4 of 7
(6,586 Views)
Sorry about that...

Here it is as 7.0
0 Kudos
Message 5 of 7
(6,586 Views)
Okay, so basically I need to modify the "Read from Spreadsheet File VI" to output an array of strings instead of numbers? If that's the case I'm not quite sure what "instructions on the diagram" you are referring to. Can you elighten me further? Thanks.
0 Kudos
Message 6 of 7
(6,586 Views)
On the diagram of Read From Spreadsheet, there is a string on the bottom labeled instructions. The last line starts "You can modify..". That's the instructions. Step by step, right click on the SGL array labeled type (empty) and select show control. Go to the front panel. Right click on any of the numeric indicators of the all rows array, select Replace and choose a string indicator from the palette. Do the same thing with the first row array. Right click on the numeric control of the type array and select replace and choose a string control. In the format control, change it from %.3f to %s. Right click and select Data Operations>Make Current Value Default. Now you need to save it. From the file menu, select Save As. I called mine Read Str
ings From Spreadsheet but you can name it whatever you want. DO NOT save it to file.llb where the original is. I wouldn't recomend saving it anywhere in the LabVIEW folder.
0 Kudos
Message 7 of 7
(6,586 Views)