LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a String array of time stamps into timestamps array

Solved!
Go to solution

Hi everyone,

 

I am trying to convert a String array of time stamps into an actual timestamps array. I have a text test/experiment data file and i wanted to just get the time stamps column data to an actual timestamp array for graphs.

 

I was able to just get the time stamps data into a string array and i am not sure how i can get it into a timestamp array. if there is a better way to get the string timestamps into a graph i could use that too. please let me know any suggestions or recommendations.

 

I have attached my VI and a copy of the text experiment data file to read from.

(NOTE: the actual exp data file is a ".dat" file and i had to convert it as ".txt" file to insert it in here, not sure if that will be a problem)

 

Please let me know if you any any questions for me.

 

Thank you!!

 

Iron_Hide

Download All
0 Kudos
Message 1 of 7
(1,894 Views)

If you go to

 

Programming -> Timing -> date and time to seconds

 

Right click on the input and select create control.  Unwire that control from the date and time to seconds and wire it into a bundle by name.

 

Split your text string up into month, day, year, hour, minutes, seconds, etc. convert them all to numbers and wire it into the bundle by name.Take the output of that bundle by name and wire it into "date and time by seconds"

 

You have to deal with daylight savings time somehow.

 

PS  Maybe someone else can tell us where to find "date time rec" variable. 

Message 2 of 7
(1,892 Views)

No need for all that. Scan from String can analyze timestamps. For your data, use a scan code of:

 

%<%Y/%m/%d %I:%M:%S %p>T

 

Example_VI.png

 

You can also use similar codes with Scan from File, but you said you only needed the timestamp column. This will get you just the timestamp; if you want to scan the whole row, you can add more format codes to the end.

Message 3 of 7
(1,872 Views)
Solution
Accepted by Iron_Hide

Hi everyone,

 

I did some search and trial and error to figure out just what i needed. Here is a snip of the code i ended up with, its just a simple couple of blocks and a for loop added to the original code i posted. Hope someone can use this discussion thread for their applications.

 

Timestamps.PNG

Thanks,

Iron_Hide

0 Kudos
Message 4 of 7
(1,840 Views)

Hi Tom,

 

Thanks a lot for the suggestion. 

 

-Iron_Hide

0 Kudos
Message 5 of 7
(1,836 Views)

Hi BertMcMahan,

 

Thanks for this suggestion too, i came across this solutions from the NI knowledge post. The only thing i had to add to this was how to get all the time stamps as an array which works with the for loop.

 

Thank you.

Iron_Hide

0 Kudos
Message 6 of 7
(1,832 Views)

Hi Iron,

 


@Iron_Hide wrote:

The only thing i had to add to this was how to get all the time stamps as an array which works with the for loop.


Now you should learn about autoindexing with (FOR) loops!

Then you can get rid of all that IndexArray and ConditionalStop inside the loop…

 

Btw. when using AutoCleanup improves your block diagram then your coding style should improve too!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(1,816 Views)