LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save 2D array to text file and read it

Hello everyone, Newbee question again... I have the following VI where I am successfully acquiring the data from my NI DAQ 6009. I am also saving the data into the text file (i got the example for saving from our NI forum). I wanted to ask you if I could read the data (both columns) and plot them one against the other. Thanks for your help.
0 Kudos
Message 1 of 16
(8,540 Views)

Of course you can do that.  In the File palette the Read VIs are usually adjacent to the Write VIs.  You did not say whether you used the Write to Spreadsheet File.vi or one of the other file write VIs.

 

After your read the data you may need to convert the strings back to a 2D array of numbers.  Use the XY Graph for your plot.

 

Lynn

0 Kudos
Message 2 of 16
(8,536 Views)

I tried to read it with the read file function but i think i am making some mistakes. here is the VI. maybe you could give me some specific hints. 

 

thanks for your quick response!

0 Kudos
Message 3 of 16
(8,534 Views)

I was surprised that that worked at all.  You have an empty format string on the Array to Spreadsheet String function.  I would have expected that to produce an error or an empty output string but apparently produces a default result similar to "%.6f".  The detailed help documentation does not describe what the function does with an empty string or an invalid specification.

 

You should be able to read your files directly using Read fromSpreadsheet File.vi.  You might need to transpose the data.  You will get a blank row (or column) corresponding to your header. Notice that there is a "transpose?" input to the VI so that you do not need to transpose the array externally.

 

Lynn

0 Kudos
Message 4 of 16
(8,527 Views)

You are right about the %.6f being default. well, i did try to read the file with the read from spreadsheet file function but my problem is that the moment the sequence finishes, I want to read the file and put it in a graph. I don't know if i can get the file info to the read spreadsheet function right after the loop/sequence ends. 

 

once again thank you for your kind help. 🙂

0 Kudos
Message 5 of 16
(8,522 Views)

If you look at the attached VI, I have tried to use the read from spreadsheet vi where empty file path invokes a dialogbox to choose file but then my header is read as 0. At the same time when I try to use the XY plot then it give me the connection error and then waveform graph just plots both the columns. huh!! I feel stupid 😞

 

I wanted to automate it after the sequence but even manual could be a solution if the automated process is not possible. 

0 Kudos
Message 6 of 16
(8,520 Views)

Bump...

0 Kudos
Message 7 of 16
(8,501 Views)

XY plot take a very different data format than waveform plots.  Please look at the LabVIEW help on the subject, since there are several variants.  In your case, you can probably fix the issue with the following change:

 

2DArrayToXYPlot.png

 

That is an index array followed by a bundler.  If there is a transpose issue, switch which input index is disabled on the index array primitive.

0 Kudos
Message 8 of 16
(8,490 Views)

1. aha the indexing is a problem and i didn't understand your suggestiong completely. could you please elaborate a little. 

 

Attached is a sample data file where first column is the time and the second column is the mean values. i wanted to plot it on xy plot as y = mean and x = time. 

 

2. As you might notice in the data file that the time which is starting time-t0 is not equidistant. any idea why that is happening? I am using NI DAQ 6009. 

 

Thanks for your kind help. 

0 Kudos
Message 9 of 16
(8,483 Views)

Ok after you suggested and surfing around our lovely forum i found the solution. Here is the link for other users who are confused about this:

http://forums.ni.com/ni/attachments/ni/170/356460/1/graph%20columns.PNG

 

 

The question remains how to read the created data file after the sequence ends automatically. I am trying to do it this way but it doesn't work. 

 

regarding the equdistant time values, I still have no clue. 😞

 

Thanks!

 

Here is the modified VI

0 Kudos
Message 10 of 16
(8,475 Views)