09-28-2023 11:37 AM
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
Solved! Go to Solution.
09-28-2023 11:52 AM - edited 09-28-2023 11:53 AM
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.
09-28-2023 12:14 PM
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
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.
09-28-2023 01:15 PM
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.
Thanks,
Iron_Hide
09-28-2023 01:17 PM
Hi Tom,
Thanks a lot for the suggestion.
-Iron_Hide
09-28-2023 01:20 PM
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
09-28-2023 01:40 PM
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!