How to quickly search over a large number of files using python?

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed Sep 25 06:00:22 EDT 2013


On 25 September 2013 09:41,  <dwivedi.devika at gmail.com> wrote:
> I am a newbie to python.
>
> I have about 500 search queries, and about 52000 files in which I have to find all matches for each of the 500 queries.
>
> How should I approach this? Seems like the straightforward way to do it would be to loop through each of the files and go line by line comparing all the terms to the query, but this seems like it would take too long.

That would be the obvious way to do this.

> Can someone give me a suggestion as to how to minimize the search time?

What do you mean by a "query"? (Code indicating how a query would
match would be helpful here.)


Oscar



More information about the Python-list mailing list