LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading files

Hallo,

this time I have two questions, I hope somebody can help:

1) I want to read a spreadsheat-file into an array, but WITHOUT the first two lines. How can I do that? I know how to read the data, but not how to ignore the first lines.

2) After the calculation I have two columns of data, x and y. I weant to save them in a spreadsheat-file like

x y
1 2
3 4 etc.,

(seperated by tab; title not nescessary)

I managed write single data into the file, but not the entire array.

Arno

PS: I am using LabVIEW 7, you can answer in german, english or dutch.
0 Kudos
Message 1 of 4
(2,761 Views)
Hi,
Happy to see you again.
Here's a little example of what you could do.

I've got a generic VI that I often use when I want to convert a file to a 1D array. I've attached this VI and used it in a new one to convert the array to a 2D one.
Choose then the subarray that you want and it should be all right I think.

Hope this helps !
Julien

P.S : thank you for telling on which LV Version you work on and the languages available.
0 Kudos
Message 2 of 4
(2,760 Views)
Reading: Easiest is to use the high-level File VIs. Just read two lines, then read the rest as spreadsheet.

Writing: Just use "write to spreadsheet". If you want to write two lines first, preceed it with "Write characters".

I have attached a simple example which also writes two header lines (So you can practice reading and writing the same sample files). Modify as needed.
0 Kudos
Message 3 of 4
(2,760 Views)
Reading may be done using the read file function and setting the "read line" boolean to true. The attached vi does this task allowing you to set the number of lines to discard as well as the number of lines to read. I have written the utility to interpret the text as double precision floating point numbers. You will have to adjust the data type on the block diagram to suit your needs.

When it reads the last line, it gets error 4, "end of file encountered". This is exactly what you wanted it to do. You should ignore this error. Turn off automatic error handling for this vi and it is a fairly efficient way to handle your task.

The file writing portion is a single call to the Write Spreadsheet File.vi"

-jayme
jc
Mac 10.4
LV7.1
CLD
Download All
0 Kudos
Message 4 of 4
(2,760 Views)