View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Load text file into memory for searching?

Can you loop through the file once, but loop through the keys?

do until eof
read a record
for each key
check it, write it (a combined file or new file for each key???)
next key
loop



J@Y wrote:

That is essentially what I am doing right now. I am searching through the big
file to pull out sections into another text file. For example, I had 13 keys
I was searching and it returned me another text file with 13 paragraphs That
takes about 2 minutes because it literally runs through the whole text file
13 times. What I like to know is if there's any way of speeding that process
up.

Thanks.

"Dave Peterson" wrote:

Maybe you could look for your keys in the text file and create a new (much, much
smaller) text file based on what you find.



J@Y wrote:

It is. Because right now, I have something that searches through the text
line by line with textCompare and it is quite slow (averaging about 3-4
seconds per search). Will the Binary method help in speeding things up?

I remember a friend once told me that if you load a text file into memory
and perform binary search, the maximum amount of time is equal to Log(N) vs
if you read it line by line its maximum time is N. I'm new to programming so
if someone can enlighten me on this, it'll be much appreciated.

"NickHK" wrote:

Check out the Open statement in the VBA Help: Their example of
Open "TESTFILE" For Binary Access Write As #1

However, if this is connected with your 1 ~ 5 million row text file, you
will probably have to do it in chunks.

NickHK

"J@Y" wrote in message
...
Is it possible to load a text file into memeory and perform binary
searches
to increase speed?




--

Dave Peterson


--

Dave Peterson