search speed

Diez B. Roggisch deets at
Fri Jan 30 09:49:46 CET 2009

anders schrieb:
> Hi!
> I have written a Python program that serach for specifik customer in
> files (around 1000 files)
> the trigger is LF01 + CUSTOMERNO
> So a read all fils with dirchached
> Then a loop thru all files each files is read with readLines() and
> after that scaned
> Today this works fine, it saves me a lot of manuall work, but a seach
> takes around 5 min,
> so my questin is is there another way of search in a file
> (Today i step line for line and check)
> What i like to find is just filenames for files with the customerdata
> in, there can and often
> is more than one,
> English is not my first language and i hope someone understand my
> beginner question
> what i am looking for is somting like
> if file.findInFile("LF01"):
> .......
> Is there any library like this ??

No. Because nobody can automagically infer whatever structure your files 

alex23 gave you a set of tools that you can use for full-text-search. 
However, that's not necessarily the best thing to do if things have a 
record-like structure. The canonical answer to this is then to use a 
database to hold the data, instead of flat files. So if you have any 
chance to do that, you should try & stuff things in there.


More information about the Python-list mailing list