LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading an array within a textfile ROW by ROW

In a textfile I stored data in an array format.
The most left column contains the timesteps dt and the other columns
contain data of different measurements. It looks like:
dt data1 data2 data3
0.543 7 8 4
0.534 6 9 5
0.553 7 5 9
etc...
considering that the timesteps dt are not uniformly ditributed.
I would like to get the data out of the textfile row by row, that is,
I would
like to control which time respectively which data to read.
The "read from spreadsheetfile.vi"-tool does only read the whole
textfile
at once. It would be great if there is a possibilty to read row by row
using
for example a loop. And then I have to get each data out of the rows
in order
to bundle them.
The whole idea behind that problem is to creat
e chart(e.g. waveform)
considering
that the x-axis (timesteps) is not uniformly distributed.
Thanks, MARC
0 Kudos
Message 1 of 8
(3,524 Views)
Hi Marc,
find attached VI ... it's reading every line and gives you both one array (that line) and the time stamp. You can handle these as you want in order to build another array or anything else.
Hope this helps ...
p.s.: that delay is just for you to have time to see every loaded line
0 Kudos
Message 2 of 8
(3,524 Views)
Yes this is a good way of pulling out a single line from a spreadsheet file. The "read lines from file.vi" is what the "read from spreadsheet file.vi" is using as a subvi.

Michael Aivaliotis


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 7 of 8
(3,524 Views)
Well, have you thought of using an XY graph? It allows the placement of arbitrarily spaced data. You can use all your dt points as the X values without the concern of indexing it out.

Michael Aivaliotis


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 3 of 8
(3,524 Views)
Yes, I did have in mind to use the XY graph. But the problem is, the
XY-graph requires bundling each single dt point and the corresponding
value of measurement. But using the "read from
spreadsheetfile.vi"-tool only allows to get whole rows out of a
textfile-array. So, the intrinsic problem I have is to get each single
row of the text file for example "for loop" by "for loop", so that I
may get for example just one dt point out of the textfile after one
loop. Have you got an idea to solve this problem?


On Sat, 3 Nov 2001 09:12:18 -0800 (PST), valiot wrote:

>Well, have you thought of using an XY graph? It allows the placement
>of arbitrarily spaced data. You can use all your dt points as the X
>values without the concern of indexing it out.
>
>M
ichael Aivaliotis
0 Kudos
Message 4 of 8
(3,524 Views)
It is hard to know exactly how deep into the text file to go and where to stop to get exactly what you want. Text files are known to be unpredictable as far as data locating. Unless the file is in binary form or a datalog, you will have a hard time doing random data access. The reason is for example, 1 data point could have 3 characters (156) or 1 character (1). So this makes specifying the start and stop indexes of the file difficult to pinpoint.

However, if you don't mind reading the whole file and processing it later then it is simple to plot a specific trace Y vs. time X. I've attached some LabVIEW code in LV6 which can do this. You never specified version so i can send it in 5.0 if you like. There I use the index array functions to ext
ract exactly what you need from the data array after it has been opened. You don't really need to use a for loop.

Michael Aivaliotis


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 6 of 8
(3,524 Views)
Yes, I did have in mind to use the XY graph. But the problem is, the
XY-graph requires bundling each single dt point and the corresponding
value of measurement. But using the "read from
spreadsheetfile.vi"-tool only allows to get whole rows out of a
textfile-array. So, the intrinsic problem I have is to get each single
row of the text file for example "for loop" by "for loop", so that I
may get for example just one dt point out of the textfile after one
loop. Have you got an idea to solve this problem?
On Sat, 3 Nov 2001 09:12:18 -0800 (PST), valiot wrote:

>Well, have you thought of using an XY graph? It allows the placement
>of arbitrarily spaced data. You can use all your dt points as the X
>values without the concern of indexing it out.
>
>Mic
hael Aivaliotis
0 Kudos
Message 5 of 8
(3,524 Views)
I've been using the vi " Read Lines from a file" under the FILE I/O.
It defaults to one line and also outputs where the line stopped so you
use that as start of next line. Use a loop and shift register o pas
sto mark as start of next line.
I've been reading a text file holding memory address & value this way
On Sat, 03 Nov 2001 07:57:18 GMT, marc.arndt@gmx.de wrote:

>In a textfile I stored data in an array format.
>The most left column contains the timesteps dt and the other columns
>contain data of different measurements. It looks like:
>dt data1 data2 data3
>0.543 7 8 4
>0.534 6 9 5
>0.553 7 5 9
>etc...
>considering that the timesteps dt are not uniformly ditributed.
>I would like to get the data out of the textfile row by row, that is,
>I would
>l
ike to control which time respectively which data to read.
>The "read from spreadsheetfile.vi"-tool does only read the whole
>textfile
>at once. It would be great if there is a possibilty to read row by row
>using
>for example a loop. And then I have to get each data out of the rows
>in order
>to bundle them.
>The whole idea behind that problem is to create chart(e.g. waveform)
>considering
>that the x-axis (timesteps) is not uniformly distributed.
>Thanks, MARC
0 Kudos
Message 8 of 8
(3,524 Views)