Jump to content
Sign in to follow this  
ParoXsitiC

Reading end lines of a file (Tail)

Recommended Posts

ParoXsitiC

The only thing I have seen was everyone recommending Randallc's TailRW.

However, his examples seem confusing and they cause AutoIT.exe to crash. I am not sure if I am doing something wrong or it's not made for Windows 7.

Either way, I am looking for something super simple, like this:

_FileReadLine($iLine)

Where if $iLine is negative, it takes the end lines. Thus: _FileReadLine(-100) retrieves the last 100 lines of a file.

If its not possible to read lines, then I would be OK with reading a number of [b/b]ytes. I am also interested in reading in the first 100 lines without loading all of them.

Please don't recommend using FileReadToArray and processing it that way. I am looking for something that can do a 5-10GB file in under 1/2 second.

Edited by ParoXsitiC

Share this post


Link to post
Share on other sites
AdmiralAlkex

Open the file in binary mode with FileOpen() and use FileRead() to read? You can use FileSetPos() to move around in the file. Sounds right in my head ;)

You need an example?

Share this post


Link to post
Share on other sites
ParoXsitiC

Open the file in binary mode with FileOpen() and use FileRead() to read? You can use FileSetPos() to move around in the file. Sounds right in my head ;)

You need an example?

I knew of FileOpen and FileRead, but not FileSetPos. However, this works good for bytes, but it would be preferable if I could indicate how many lines.

Share this post


Link to post
Share on other sites
MilesAhead

How big are the files you anticipate handling? If not that large

_FileReadToArray() reads the file into an array. $array[0] has the

count of lines. It may not be the fastest way to do it. But if you

screen out super huge files it may be simplest and therefore not bug

prone.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.