Extracting text from BIG text file?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Extracting text from BIG text file?

Post by rullbandspelare » Tue Oct 16, 2007 5:32 am

Hi!
I have a BIG log file wich is about 60MB.
I whant to extract all the lines that contain the text "ERROR" and all the following lines until a "----------" is reached. This is appended to a ERROR.log file

I have this working but it takes a LOOOONG time. With a smal log file it is no problem.

I use the Windows XP command >find "ERROR" largefile.log.0 /N to get the line numbers of lines wich contains "ERROR". This is fairly fast.
Then i extract all the lines in this list + following lines until "-----" is encountered.

At first it is fast but when row numbers increase it gets slower and slower.

Any design ideas on how to do this faster?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 16, 2007 7:33 am

You don't provide any information as to how you are reading the file in. ReadLn will be very slow on big files. ReadFile would be much faster. See:
http://www.mjtnet.com/blog/2007/07/02/r ... in-memory/

Alternatively you can read text files with VBScript using the FileSystemObject and OpenTextFile (search for those on this forum).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts