FileSystemObject to get last 10 lines of text file.
Hi Tom,
Thank you for the insight.
I expect a Sequential read, would be most appropriate to the file, as it has
random bits throughout and a header line... (the file is at work, that's why
no sample supplied sorry)
When you say "you can read the 1 to n bytes into a string and then loop
backwards from the eof" ...would you mind explaining how would this be
achieved?
Tom Ogilvy wrote in message
...
What do you know about the file. Are all lines exactly the same length?
There is no magic to reading a file - it is a sequential read in most
cases.
A file is one to n bytes. The concept of a line is defined in Windows by
encountering a crlf combination. Anything that would be faster would
involve calculating where to put the file pointer and if your lines aren't
equal length, the alternative is to read the data and count the lines.
That
said, you can read the 1 to n bytes into a string and then loop backwards
from the eof.
Look at the objects/properties/methods of textstream in the scripting
runtime and you will see there aren't any special methods beyond what I
have
described.
Regards,
Tom Ogilvy
john wrote in message
...
Hi there,
I am interested in finding out how to read the last 10 lines (or so) of
a
text file using the FileSystemObject function, rather than looping
through
a
text file line-by-line until the end is reached then working backwards.
I may be looking at reading the last 10 lines of a large text file
almost
every second, and would be interested in the fastest method available.
If anyone can explain how this could be done, I'd be very grateful!
Thank you.
|