LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from string error

Hello again

 

The VI below is supposed to read data from file and then check line by line if any timestamp is missing and if it is, insert an empty line in between and write to a modified file.

 

This is an example of file read:


20211020 07:29:39 103.5067 0.7903628 23.50795 32.2836 23.622 32.06245 23.63304 32.04114 23.54106 32.21922 23.58889 32.12648 23.08115 33.12648 23.70663 31.89947
20211020 07:29:40 105.4954 0.7365419 23.50856 32.28242 23.6079 32.08971 23.66309 31.98322 23.68516 31.94073 23.68884 31.93365 23.1443 33.00021 23.73299 31.84889

20211020 07:29:42 107.376 0.6895261 23.49107 32.31646 23.65664 31.99563 23.67872 31.95312 23.68976 31.93189 23.70447 31.90361 23.21145 32.86656 23.7523 31.81189
20211020 07:29:43 109.1772 0.6477419 23.44769 32.40114 23.51023 32.27915 23.55807 32.18621 23.58014 32.14342 23.57646 32.15055 23.09447 33.0998 23.62429 32.05803

 

First data is a date, second is time stamp.

 

modifyfile.png

 

So my problem is that the scan from string function throws an error when i try to convert from timestamp string to timestamp, but seems to do so at random. Probing the lines didn't help as the string seems to be correct, yet function throws an error.

0 Kudos
Message 1 of 3
(1,604 Views)

Turns out string format was wrong, besides the time hh:mm:ss it also expected date in MM:DD:YYYY, once i added dummy date it worked fine.

 

Still don't know why it sometimes worked without the date and sometimes not.

0 Kudos
Message 2 of 3
(1,587 Views)

The %T format specifier expects whatever your local time and date format is for the country settings you have in your computer.

 

If you have a specific format you have to specify it in the format explicitly:

 

%<%Y%m%d %H:%M:%S>T

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 3
(1,578 Views)