Tags: calls, file, incolum, labview, line, program, programming, reading, sizes, text, vary, writing

Reading last line in a text file? Not possible?

On Programmer » LabVIEW

2,199 words with 2 Comments; publish: Wed, 30 Apr 2008 09:53:00 GMT; (200125.00, « »)

The program I am writing calls a file and I want to read the last line in

colum one.

This is easy enough except that the file sizes vary so I need to somehow sca

n

the file when it loaded and report the last line value to an indicator.

Any ideas?

Thanks!

All Comments

Leave a comment...

  • 2 Comments
    • n2new.labview.todaysummary.com.aol.comNsheep (NoSheeples) wrote in

      news:20041024023350.02596.00002528.labview.todaysummary.com.mb-m13.aol.com:

      > The program I am writing calls a file and I want to read the last

      > line in colum one.

      > This is easy enough except that the file sizes vary so I need to

      > somehow scan the file when it loaded and report the last line value to

      > an indicator. Any ideas?

      >

      If the lines in the file is of different lenghts then you need to scan

      for the last line.

      I guess you know approximately how long the longest line is, Then you

      can use the "Read File" function and the "pos mode" and "pos offset"

      inputs to just reading for example the last 100 characters of the file

      and find the last line there.

      Not a complete answer but i hope this can help you a little bit.

      Rolf

      #1; Wed, 30 Apr 2008 09:54:00 GMT
    • Hi,

      You could read the last x characters, check if there is an \n in it. If so,

      split the string, if not read the previous x characters, and attach it

      before the first string. Check if \n is in it, and repeat until the begin of

      the file or a \n is encountered.

      Regards,

      Wiebe.

      "Rolf stvik" <rolfostvikjobb.labview.todaysummary.com.yahoo.no> wrote in message

      news:Xns95906131BB1A9rolfostvikjobbyahoo

      n.labview.todaysummary.com.195.70.164.134...

      > n2new.labview.todaysummary.com.aol.comNsheep (NoSheeples) wrote in

      > news:20041024023350.02596.00002528.labview.todaysummary.com.mb-m13.aol.com:

      >

      > If the lines in the file is of different lenghts then you need to scan

      > for the last line.

      > I guess you know approximately how long the longest line is, Then you

      > can use the "Read File" function and the "pos mode" and "pos offset"

      > inputs to just reading for example the last 100 characters of the file

      > and find the last line there.

      > Not a complete answer but i hope this can help you a little bit.

      > --

      > Rolf

      #2; Wed, 30 Apr 2008 09:55:00 GMT