Tags: avoid, forced, fromstring, labview, programming, reading, scan, stringswhenever, timestamp, working

Reading in a timestamp

On Programmer » LabVIEW

2,066 words with 3 Comments; publish: Sun, 18 May 2008 21:07:00 GMT; (20091.80, « »)

Thanks for the quick help. I really avoid working with strings

whenever possible, but now I'm being forced to. I tried the Scan From

String with the format you suggested, and I kept getting an error ("too

many format specifiers"). I'm attaching a vi with what I'm doing. 

; If

you (or anyone) has a chance to look at it, I would love any more

advice.

Timestamp Problem.vi:

http://forums.ni.com/attachments/ni...864/1/Timestamp Problem.vi

All Comments

Leave a comment...

  • 3 Comments
    • You get the message "too many format specifiers" because you used the format

      string I told you, but with only one output.

      You need 6 outputs if you're reading six parts (mm DD YYYY HH MM SS.s).

      Of course, that won't work either if you put in a string that starts out "Lo

      g File"

      You probably should read the file with "%s" format, and get an array of

      strings.

      Throw away the first line of commentary stuff.

      Strip out the first column.

      For every row in the first column, run the string through the SCAN FROM STRI

      NG function, and maybe the DATE/TIME to SECONDS function to get a timestamp

      value.

      Then run the rest thru a STRING TO NUMBER conversion (no loops needed) to ge

      t your data.

      HTH

      #1; Sun, 18 May 2008 21:08:00 GMT
    • Forgot to mention, use

      %<%m/%d/%Y %H:%M:%S%1u>T

      as your scan string, and it will output a timestamp.

      #2; Sun, 18 May 2008 21:09:00 GMT
    • You're only getting a 2 because you're using read from spreadsheet file and

      returning doubles. When the timestamp string gets converted to a double, it

      sees "02/..." It doesn't know how to convert a slash into a double so it ass

      umes the number ends there.

      I suggest you wire a %s to Read from Spreadsheet File. This will give you al

      l the data in strings. Now you can take out the first column and convert it

      to timestamps (using Scan from String), then take out all the actual data an

      d convert it to doubles.Mes

      sage Edited by Marc A on 03-01-2007 11:20 AM

      #3; Sun, 18 May 2008 21:10:00 GMT