LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Data from CSV file to XY chart

Solved!
Go to solution

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:

VI.png

 

 

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.

 

Download All
0 Kudos
Message 1 of 12
(6,743 Views)
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
(6,729 Views)

You should use read text file and scan from string.

scan.png

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

Message 3 of 12
(6,711 Views)

@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.


GCentral
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
(6,703 Views)

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

Message 5 of 12
(6,693 Views)

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)

 

VI.png

 

 

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:

VI.png

 

 

0 Kudos
Message 6 of 12
(6,610 Views)

File path is empty. Of course vi return error.

0 Kudos
Message 7 of 12
(6,595 Views)

@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.

Download All
0 Kudos
Message 8 of 12
(6,583 Views)
Solution
Accepted by topic author xpress_embedo

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
(6,564 Views)
Solution
Accepted by topic author xpress_embedo

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
(6,556 Views)