Sign in to follow this  
Followers 0
dodger42

Read last line from file

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Perfect, thanks Smoke.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0