Jump to content

Read last line from file


Recommended Posts

I have looked at the read from file functions, but can't seem to find a way to read the last line.

Is there a way to do this, even if I have to count the number of lines and then choose via filereadline.

Any suggetions?

Link to comment
Share on other sites

  • Moderators

I have looked at the read from file functions, but can't seem to find a way to read the last line.

Is there a way to do this, even if I have to count the number of lines and then choose via filereadline.

Any suggetions?

Look at _FileCountLines() in the Beta help file then use the number it returns with FileReadLine(), should only be 2 lines of code.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Perfect, thanks Smoke.

If you are working with very large files , you may wish to write a wrapper for the command line tail utility.

head and tail are designed to swiftly get you the leading or trailing lines in a file; many ports from their unix roots are available. Of course, you would have the overhead of firing up the console session, and handling the resulting output.

_FileCountLines depends on a FileRead() operation that can bog down on large files. I've never used the StringAddCR() function, so I don't know how efficient it is.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...