LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two column csv to waveform graph

Solved!
Go to solution
Part of my VI reads data from a csv file. It has two columns, one is time of sample in 24hr format (24:00) the other is the reading which is an integer. I am having trouble figuring out how to map these columns to a graph. It appears to display the data points properly but does not show my time of reading along the x-axis. I attempted to break apart the file and then bring it back together but have had no success. Any help would be greatly appreciated.
Download All
0 Kudos
Message 1 of 19
(4,555 Views)

For others, code originated from this thread, though this is an addition to that code, and a new question.

 

To the question: The reason why you're not getting the time correctly is because you are reading the file and telling the Read From Spreadsheet File VI to parse integers. The text "10:39" is not an integer. Thus, it returns you the part of that text which is an integer, which is 10. To correctly parse the file you should read it in as a 2D string and then parse each line to convert 10:39 to a valid timestamp. 

 

P.S. The code in the frame sequence should be in a subVI. And the frame sequence is also not necessary. 

Message Edited by smercurio_fc on 09-03-2009 01:19 PM
Message 2 of 19
(4,547 Views)

smercurio_fc wrote:

For others, code originated from this thread, though this is an addition to that code, and a new question.

 

To the question: The reason why you're not getting the time correctly is because you are reading the file and telling the Read From Spreadsheet File VI to parse integers. The text "10:39" is not an integer. Thus, it returns you the part of that text which is an integer, which is 10. To correctly parse the file you should read it in as a 2D string and then parse each line to convert 10:39 to a valid timestamp. 

 

P.S. The code in the frame sequence should be in a subVI. And the frame sequence is also not necessary. 

Message Edited by smercurio_fc on 09-03-2009 01:19 PM

Thanks!  (and kudos)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 19
(4,539 Views)
Sorry about not linking my original question. In order to split the 2D array coming from the spreadsheet vi which tool can I use? I keep trying to wire it to different ones but get the usual broken wire. Thanks.
0 Kudos
Message 4 of 19
(4,521 Views)
Use a for-loop autoindexed from your 2D array. The for-loop will run for each row. Inside the loop use an Index Array expanded to two elements to get column 0 and column 1 for that specific row. Then you can parse each string as needed.
Message 5 of 19
(4,513 Views)
I definitely see what you mean but seem to have trouble wiring it in. I wired the iteration to the index-0 on the index array then wired a constant to the N terminal for troubleshooting purposes but then I do not get any values for my output. Thanks again for the help.
0 Kudos
Message 6 of 19
(4,475 Views)

icemaker wrote:
I wired the iteration to the index-0 on the index array then wired a constant to the N terminal for troubleshooting purposes but then I do not get any values for my output. Thanks again for the help.

That makes absolutely no sense. The iteration terminal should not be connected at all, nor should a constant be wired to the N terminal. The loop automatically runs for as many rows as you have in your file. For the moment forget the rest of the code and concentrate on reading the file and parsing the numbers.

 

Step 1: Create a VI with just the code I showed you, and run it in highlight mode then you will see the indicators update based on each row. The Read From Spreadsheet File VI will ask you for a file since there is no path wired to it. In your full code you would obviously wire the path. 

 

Step 2: Add string to number conversions on the wires coming out of the Index Array so you can actual numbers.

 

Step 3: Build an array out of the 2 numbers you have, and then wire the array out of the loop. Autoindexing will automatically give you a 2D array. You can then connect this to a graph.

 

Step 4: Copy the code into your full VI, making sure to connect the path to the Read From Spreadsheet File.

Message 7 of 19
(4,465 Views)
Since my time is in 24hr clock. What is the best way to interpet this for the graph? I can parse and split at the : but I am unsure of how to put it back into a format that the chart will take.
0 Kudos
Message 8 of 19
(4,410 Views)
You can simply convert the time to seconds. A timestamp in LabVIEW is a datatype that corresponds to the number of seconds since 12:00 a.m., Friday, January 1, 1904, Universal Time. If you parse it into a timestamp then use the To Double Precision Float numeric conversion function to get a DBL representing the seconds since that LabVIEW starting time. The graph/chart can be configured for either relative time or absolute time.
0 Kudos
Message 9 of 19
(4,402 Views)

I converted my 24hr time to seconds. I tried two things, wiring as seen in picture below. And also tried converting to time stamp as you suggested. When I make it a timestamp I get a broken wire when I put it into the array.

 

 

time.png

0 Kudos
Message 10 of 19
(4,386 Views)