LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

Plotting Data from CSV file to XY chart

Hello Everyone,

I have to read data from a Spreadsheet (*.CSV) and then plot it in LabVIEW.

The File contains three values

Time, Date, Temperatre Value

For Example, here are the Logs.

16:46:59,31/01/14,+018.2C
16:47:59,31/01/14,+018.2C
16:48:59,31/01/14,+018.2C
16:49:59,31/01/14,+018.2C
16:50:59,31/01/14,+018.5C
16:51:59,31/01/14,+018.5C
16:52:59,31/01/14,+018.5C
16:53:59,31/01/14,+018.5C
16:54:59,31/01/14,+018.5C
16:56:40,31/01/14,+018.5C
16:57:40,31/01/14,+018.5C

.

.

.

.

.

.

23:51:24,31/01/14,+015.0C
23:52:24,31/01/14,+015.0C
23:53:24,31/01/14,+015.0C
23:54:24,31/01/14,+015.0C
23:55:36,31/01/14,+015.0C
23:56:44,31/01/14,+015.0C
23:57:44,31/01/14,+014.6C
23:58:44,31/01/14,+015.0C
23:59:44,31/01/14,+015.0C

What i have to do is to create a VI in LabVIEW to visualize this data.

I did it like below:

It looks okay, but X-Axis is Time Axis and 16:46:59 it is just showing 16, i know i haven't done anything to handle this.

But i am not able to find what can i do in this case.

Please suggest how to get exact full time values on X-Axis.

Message 1 of 12
(3,701 Views)

Re: Plotting Data from CSV file to XY chart

The problem is how you are reading and formatting the data in the first column. You are just turning it into a float which will only convert up to the first non-numeric character.

You want to take the first two columns and convert them into a timestamp. Use the timestamps for the X axis values.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 12
(3,687 Views)

Re: Plotting Data from CSV file to XY chart

You should use read text file and scan from string.

Maybe your local time and separators settings gives you simpler format string.

Message 3 of 12
(3,669 Views)

Re: Plotting Data from CSV file to XY chart

@Artem.SPb wrote:

You should use read text file and scan from string.

You are close.  But there are some things in there that will mess you up, like the temperature units and the end of line character(s).  I would do something like this.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 12
(3,661 Views)

Re: Plotting Data from CSV file to XY chart

crossrulz a écrit :

@Artem.SPb wrote:

You should use read text file and scan from string.

You are close.  But there are some things in there that will mess you up, like the temperature units and the end of line character(s).  I would do something like this.

I came up with the same solution (only slower!). To add to your comments using a for loop also doesn't add an extra zero at the end.

Ben64

--------------------------------------------------
The best way to say thanks is to give kudos!
Message 5 of 12
(3,651 Views)

Re: Plotting Data from CSV file to XY chart

Thanks for the help it works. (File Path Control is diconnected in Block Diagram in this case, Read from Text block directy ask for file, if i connect the File Path Control i get an error which is described below)

But i got stuck in another problem an it is related to the File Path Control.

If i use the file Path Control i get an error as follow:

Message 6 of 12
(3,568 Views)

Re: Plotting Data from CSV file to XY chart

File path is empty. Of course vi return error.

Message 7 of 12
(3,553 Views)

Re: Plotting Data from CSV file to XY chart

@Artem.SPb wrote:

File path is empty. Of course vi return error.

I added the file path to it by clicking on folder icon.

In the path there are two files which contains logs, first is TEMP.txt and another is Temp_AmbientData.txt

The graph plotted initially is of Temp_AmbientData.txt file, now i change the File Path to TEMP.txt, when i run the LabVIEW VI, it asks for the File again, and this is due to the Read Text file block i think, and even if i specify the Temp_AmbientData.txt file now, it will plot TEMP.txt file

So my question is why the dialogue appears if the path is already specified.

Please run the VI attached you will get to know what exactly is happening.

Message 8 of 12
(3,541 Views)
Solution
Accepted by topic author xpress_embedo

Re: Plotting Data from CSV file to XY chart

Your VI contains an "orphan" bit of Read from Spreadsheet" code that has nothing wired to the File Path.  Diagram-disable (or delete) this extraneous code and your VI will run fine with Temp.txt in the File Path control.

Bob Schor

Message 9 of 12
(3,522 Views)
Solution
Accepted by topic author xpress_embedo

Re: Plotting Data from CSV file to XY chart

Incidentally, why are you plotting Date and Time on the X Axis?  Do you really need to know the date that each data point was recorded?  Wouldn't "Elapsed time" (in seconds, minutes, or hours, as appropriate for your data rate) be more useful?  If so, you can easily convert "Time" to "Elapsed Time" by creating TimeStamps (as you've done) and subtracting the initial TimeStamp (Time-zero) from all of them.  The difference of two TimeStamps is a Dbl, and represents the number of seconds between the two TimeStamps.

Bob Schor

Message 10 of 12
(3,514 Views)