View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Read .TXT file line by line?

Charlotte E. brought next idea :
How to read a .TXT-file line by line?

I would like to read the first line of the .TXT-file,
Perform some action on the read data (the .TXT-line)

Read the next line - perform some action
Read the next line - perfom the action again
etc...

Until all lines of the .TXT-file is read, and the action is performed on all
lines (imported data)

My problem is that I have a HUGE .TXT-file of almost 3.000.000 lines!!!
I'm aware that going through all these lines, one-by-one, will probably take
a week or so, so I have to make my first test-program read a smaller file,
until I'm sure it is working.

But, how to read the file, line by line, in the first place, since I can't
import such a huge file in my trusty old XL2003?

Oh, I case you wonder what the 'action' is, I want to remove those lines in
the .TXT-file that doens't fullfill certain criteria, thus (hopefully :-)
ending up with a .TXT-file of only approx. 105.000 lines, which then can be
converted into a webtable.


Thanks in advance...

CE


Not to discount others' replies here but given the size of the file[s]
you say you are working with, these are similar to files resulting from
a database 'dump'. In this case it would be far more efficient to read
the file in 'blocks' and process each line of a block in memory rather
than read/process each line one at a time. Okay for smaller files if
you don't mind the time it takes but you might not like the performance
this approach has with such large files.

You can find lots of examples/samples of large file parsers if you
google this with "VB6" included. (ie: "parse large text files vb6")

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc