LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read ASCII files Skipping past header lines

When reading back data log files for post processing how do I skip over any header lines so I can get to the data. For any one job the number of header lines is constant. I'm confused as to how to tell LabVIEW to skip over these lines!
0 Kudos
Message 1 of 4
(3,194 Views)
I am going to assume that you are not using "datalog" files, but rather, spreadsheet files with a few lines of header information.

You need to use your string functions to strip the header lines off of the file string before converting it back to an array. Look for end of line characters such as "\r" and/or "\n" to know when you have reached the end of a line.

-Jim
0 Kudos
Message 2 of 4
(3,194 Views)
The easiest way is to read that number of lines before you read the rest of the file.
Notice in the read file that you can connect line mode to true:
snippet from the help:If line mode is TRUE, and if you do not wire count or count equals 0, Read File reads until it encounters an end of line marker--a carriage return, a line feed, or a carriage return followed by a line feed, or it encounters end of file.
end snippet.
You can do this in a for loop.
Or use a special vi I stole from somewhere in the system that only counts for so many lines and calculates the offset in the file.
This last one is somewhat faster but also a littlebit more complex.
I have a lv5.1 version attached
greetings from the Netherlands
0 Kudos
Message 3 of 4
(3,194 Views)


I assume you are ussing the open file, read file, and close file Functions. If this is the case you could try this trick. Wire after file open a file read in a For loop, this file read schould be wired that it can readline, so all you need to do now is to Know when you want to skip lines and how many lines you want to skip. you can alternate this until the file ends. don´t forget at the end, to use file close.
for example :


1.file open
2.For loop with 3 loops, inside is a file read(read the first 3 lines)
3.For loop with 3 loops, inside is a file read(skip the next 3 lines)
4.For loop with 3 loops, inside is a file read(read the first 3 lines)
5.For loop with 3 loops, inside is a file read(skip the next 3 lines)
6.Close file



hope I
could help you.
0 Kudos
Message 4 of 4
(3,194 Views)