LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read time from .csv file then display time on x axis of waveform graph

Solved!
Go to solution

Hi am new to Labview, and i am measuring temperature and humdity and saving it in a .csv file with the time and date when the where saved. what i want to do is read them both and display them on a wavform graph with the date and time on the x axis. 

 

i am attaching the vi and the data file so you can see what i have already done. 

Download All
0 Kudos
Message 1 of 10
(4,555 Views)

Don't read the same file twice, once as a string, once as a double.

 

Just read it as a string.  Then convert the numeric columns to arrays using the string to number functions.  Convert the date and time columns to a timestamp using a Scan from String function.

0 Kudos
Message 2 of 10
(4,547 Views)

@RavensFan wrote:

Convert the date and time columns to a timestamp using a Scan from String function.


Won't work  Thats an excel time and date 

Add the time to the date and try XL to Time  At least it works if you set the BD Constant to midnight Local time.  It was written in Central Standard time and will display in local time.  That's ok Excel's Epoch (Time 0) is in Local time so that constant should need to change.  (I'll have to find some brilliant workaround some day)


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 10
(4,532 Views)

The CSV files are text strings.

 

If he reads them in as strings, then he can combine the date and time using string functions and feed it into a Scan from String function.

0 Kudos
Message 4 of 10
(4,529 Views)

The csv file I opened had date and time formatted as date and time  I.E. the value of time was 0.72 formatted as 17:45:53 (approx)


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 10
(4,521 Views)

@JÞB wrote:

The csv file I opened had date and time formatted as date and time  I.E. the value of time was 0.72 formatted as 17:45:53 (approx)


That's true for the times, but not for the date column. Those are just "General" format.

0 Kudos
Message 6 of 10
(4,517 Views)

@JÞB wrote:

The csv file I opened had date and time formatted as date and time  I.E. the value of time was 0.72 formatted as 17:45:53 (approx)



That's because Excel did an automatic conversion of those data points to a time stamp when it imported the .csv file.

 

The file itself is not an Excel file but pure text.  And Read from Spreadsheet File VI is going to open it up and treat it like pure text.

Message 7 of 10
(4,508 Views)
Solution
Accepted by topic author Deely

Changing as little as I could, I was able to get what you wanted. (I believe this whole program could use a bit of clean up once you get more familiar with LabVIEW - like the fact that you have a while loop that will, by definition, always only run once.)

 

Basically, the x axes are just numbers of seconds formatted to look like date & time. I changed it so that the time stamp gets set to be the Raw Data's XScale.Offset. Then, the cursor needed to have that offset subtracted to be the index of the 2D array of Raw Data.

 

Also, you were graphing the "time" as a bright green line (which I removed), and I'm guessing you didn't want that.

 

EDIT: There's an error with the scan string that I got once I uploaded it and then downloaded a copy. Working on fixing that.

EDIT: When you run it a second time, it works?

Message 8 of 10
(4,500 Views)

I give up with fixing the scan string issue. I think you should fix that whole thing because it gets today's date, which might not always be the data at which you're looking. Why doesn't it look at the date provided in the .csv file? I feel a lot of that part is unneccessary…

0 Kudos
Message 9 of 10
(4,491 Views)

Thanks to everybody for replying.

Quevvy thank you very much mate that is what i needed just wanted to display the time on the x axis of the raw data but i was trying to connect a property node to the raw data graph which was causing the data section graph to stop working. I will try and fix the error with the date aswell because i am getting the date as 12/07/13, when actually the data was saved on 17/0713. 

 

0 Kudos
Message 10 of 10
(4,462 Views)