キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Two column csv to waveform graph

解決済み
解決策を見る
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.
すべてをダウンロード
0 件の賞賛
メッセージ1/19
4,997件の閲覧回数

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
メッセージ2/19
4,989件の閲覧回数

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 件の賞賛
メッセージ3/19
4,981件の閲覧回数
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 件の賞賛
メッセージ4/19
4,963件の閲覧回数
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.
メッセージ5/19
4,955件の閲覧回数
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 件の賞賛
メッセージ6/19
4,917件の閲覧回数

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.

メッセージ7/19
4,907件の閲覧回数
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 件の賞賛
メッセージ8/19
4,852件の閲覧回数
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 件の賞賛
メッセージ9/19
4,844件の閲覧回数

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 件の賞賛
メッセージ10/19
4,828件の閲覧回数