LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading files.

Beginner here.

I have written a dyno data acquisition program in LV 6.0 (WIN XP). It
saves the data into a text file. (Several thousand lines, of 6 comma
delimited rows. (the row data varies in length)

Now I want to read that file and graph it. I am trying to use the Read
Lines From File vi. This vi only lets me index into the file using a
read offset in characters. I want to read a single line at a time. Since
I don't know the length of each row in characters, this doesn't work too
well.

Is there a better way to do this? (Obviously ). It works fine when
all the rows are of a fixed length.

Thanks
Jim
SR Racing
0 Kudos
Message 1 of 6
(2,883 Views)
Hi,

The point is that this vi returns place of last character was reading. Therefore you simply use this number as input to "Start of Read Offset" in next iteration.
Example vi attached.
I hope this will help you.

Nadav Chernin.
nchernin@chiaro.com
0 Kudos
Message 2 of 6
(2,883 Views)
>The point is that this vi returns place of last character was reading.
Therefore you simply use this number as input to "Start of Read
Offset" in next iteration.
Example vi attached.
I hope this will help you.<

Thanks Nadav, but I didn't get the attached VI. Could you send it to my
email direct?

Jim
0 Kudos
Message 3 of 6
(2,883 Views)
I'm sorry.

Now this vi is attached.
0 Kudos
Message 4 of 6
(2,883 Views)
This should work, but you could also use the Read From Spreadsheet File.vi, specify the comma as a delimiter and get your data back as an array. Using the format specifier, your data can return as a numeric array (and, yes, you can specify how many rows to read).

Just a thought.

Rob
0 Kudos
Message 5 of 6
(2,883 Views)
Hi Jim,

Another possibility...

Use instead the "Read Characters From File" function (File I/O palette) then
feed the "character string" output to the "spreadsheet string" input of
the"Spreadsheet String to Array" function (String palette). Wire a constant
string "%s" (no quotes) to the "format" string input. Wire a constant
string "," (again, no quotes) to the "delimiter (Tab)" input. Finally,
create an empty 2D string array constant and wire that to the "array type
(2d double)" input. (Easiest way to create the empty 2D string array is to
drop an array constant on your wiring diagram (Array palette). Then drop a
string constant into the array constant to make it an array of strings.
Finally, pull down on the display index at the left of the array constant to
expand it to a 2D array. You don't need to put anything into this array
since the function is only looking at this input to know what type of output
you expect to have created.)

Now the output of the Spreadsheet String to Array function should be an
array of strings correseponding to the elements in your comma delimited
file.

One caveat... this presumes that each line of data is terminated by an EOL
(end of line) character (like a carriage return).

If any of the above is unclear, please feel free to contact me directly.

Hope this helps.

Jim


"Jim Schings" wrote in message
news:3CCC9988.6B4CF19E@mindspring.com...
> Beginner here.
>
> I have written a dyno data acquisition program in LV 6.0 (WIN XP). It
> saves the data into a text file. (Several thousand lines, of 6 comma
> delimited rows. (the row data varies in length)
>
> Now I want to read that file and graph it. I am trying to use the Read
> Lines From File vi. This vi only lets me index into the file using a
> read offset in characters. I want to read a single line at a time. Since
> I don't know the length of each row in characters, this doesn't work too
> well.
>
> Is there a better way to do this? (Obviously ). It works fine when
> all the rows are of a fixed length.
>
> Thanks
> Jim
> SR Racing
>
>
>
Message 6 of 6
(2,883 Views)