Re: How to search files for text string most efficiently?
From: Richard Jalbert (richmann_at_sympatico.ca)
Date: 10/29/04
- Next message: Larry Serflaten: "Re: Threading Performance"
- Previous message: Larry Serflaten: "Re: I need speed Mr .Net....speed"
- In reply to: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Next in thread: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Reply: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 29 Oct 2004 01:43:14 GMT
On Thu, 28 Oct 2004 20:52:17 +0200, "Herfried K. Wagner [MVP]"
<hirf-spam-me-here@gmx.at> wrote:
>"Richard Jalbert" <richmann@sympatico.ca> schrieb:
>>>I am working on a small windows application for a client, and as one of
>>>the
>>>functions they want a search that will let them enter a search string,
>>>then
>>>search a directory for all flies that contain that search string AND
>>>display
>>>the lines that contain the search string.
>> [...]
>> Then using that array, get each filename, get and read by OPEN AS
>> BINARY each file, loading its content in a single one string buffer,
>> sized after getting the file size. on which you could do a "instr"
>> function.
>
>If the files are "small", that's a good approach.
Is not the maximum size for a string buffer something like 0 to 2
billion characters?
>If the files are large,
What would be a large file?
I have one that is 214 Megs (PI to a million place and I cannot open
it on my machine (I concaneted it from 20 smaller files))
>it's trickier, you'll have to read the file in chunks of a certain size and
>then perform 'InStr', notice that you will have to check for occurances that
>overlap the ends of two chunks separately.
Overlap is easily checked by reading the first buffer then when
reading the second, back the byte pointer by at least the size of the
substring to be found.
One detail that was not stated: what is the substring is split by a
vbCRLF character. this mean they would have to be removed from the
file before doing the search, no ?
**********************************************************************
Richard Jalbert Programmer-Analyst Richmann@sympatico.ca
Dogs have owners, cats have staff.
http://www3.sympatico.ca/richmann/
**********************************************************************
- Next message: Larry Serflaten: "Re: Threading Performance"
- Previous message: Larry Serflaten: "Re: I need speed Mr .Net....speed"
- In reply to: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Next in thread: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Reply: Herfried K. Wagner [MVP]: "Re: How to search files for text string most efficiently?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|