LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting data out of a textfile in labVIEW

Into a textfile I saved data from a measurement in an array format. The
file looks like:
dt data1 data2 data3
0.52 4 6 9
0.51 5 9 2
0.54 6 9 3
etc...
I now would like to create a waveform chart to display the data that is not
uniformly distributed along the X-axis.That is, I have to read from
the textfile row by row and I have to get every single data - time, data1,
data2
and data3 - in order to bundle the data correctly. The question is:
How can it be achieved to read from an existing textfile row by row
respectively
how can I figure out each single date of each row and column instead of
getting the the content of the file at once like the "read from spreadsheat
file.vi"?
Hope that someone has got a solution to my proble
m!
Thanks!
MARC
0 Kudos
Message 1 of 4
(2,976 Views)
In order to display non-uniform x axis, you have to use an XY Chart and not a graph. The attached example shows how to use Read From Spreadsheet File to accomplish what I think you're trying to do. The manipulation of the dT data is to display the Y values in absolute time. There are other examples that come with LabVIEW that show how to display a varying time x axis.
0 Kudos
Message 2 of 4
(2,973 Views)
I had a similar problem in that I had spreadsheet data (x=timestamp in ms, y=voltage)which was sampled at a non-uniform sample rate (non-deterministic sampling loop), stored in a spreadsheet, that I wanted to operate upon using the waveform tools in labview, but the waveform data type requires a constant dt.

I solved this problem by first calculating the average sample rate of the original data, then interpolated the y values onto these new timestamps (now of equal dt).
The VI I used to do this is below, as well as the sample dataset I used to test the vi. My application needed double precision numbers reading from the spreadsheet, hence the re-written read from spreadsheet file vi included.

The sample dataset is simply two columns representing time (ms) and voltage. I simulated a sinusoidal voltage. I randomised the sample time so that the dt between samples is 6ms +-(some fraction of 2.5ms at random) - ie a non-uniform dt (the sample file contains extra columns used to produce the simulated dataset).

The VI creates a waveform of the interpolated data. It also plots the original data in x-y format alongside the interpolated data in x-y format so you can see the interpolation errors and non-uniform vs uniform dt's of the two datasets.

unzip the zip file, Run the VI "resample example.vi" (labview ver 7.1), browse to the text file in the zip which contains the test data.

look at the block diagram for notes.

Ive probably done overkill on this - no doubt someone will come up with a more elegant way of making non-uniform-dt data into a waveform type (or just tell me to find a way to sample at uniform dt in the first place!)

Steve
0 Kudos
Message 3 of 4
(2,915 Views)
I knew it! there is a vi that already does some of this.
You can perform the conversion between x-y data and waveform type using the
"resample waveforms (single shot).vi"
found under functions > analyse > waveform conditioning.
the trick of finding the average dt from the x dataset is still useful as it can be fed into the resample waveforms vi to create a reasonable dt for the dataset.
Steve
0 Kudos
Message 4 of 4
(2,906 Views)