Tags: advanced, file, functions, labview, line, menu, programming, reference, retrieve, sub, text

I need to retrieve only the first and the last line of a text File

On Programmer » LabVIEW

1,554 words with 0 Comments; publish: Wed, 30 Apr 2008 11:24:00 GMT; (20046.88, « »)


In the file I/O functions there is an Advanced File Functions sub menu.

There you can open a reference to a file, and read data from it. The first

line is easy, just use Read File, and set the Line Mode (F) to true.

The last line is a bit trickier. You can use the S function to get the

length of the file. Set a counter to this position-1. Read one character

from this position. Subtract the position with one, and read another

charater. Put is before the previous string. Repeat until a \n is


If you know how long the last line is going to be at maximum, you can read

this number of characters, and split the string on the last \n. This is

easier but not general appliable.

Also think about what you want to do when the last line is the first line.

Note that this method is only worth the effort when the files get large

(below a few MB I'd use a method like suggested by Dr. Imad).



"Jules K." <x.labview.todaysummary.com.no.email> wrote in message news:169785.labview.todaysummary.com.exchange.ni.com...

> I would be very happy if some one of you can help me.<br>I attached a text

File as example<br>thanks<br><br>Jules


> text_file.txt:

> http://forums.ni.com/attachments/ni...1/text_file.txt

All Comments

Leave a comment...