efficient text file search.
bill.scherer at verizonwireless.com
Mon Sep 11 14:51:42 CEST 2006
>Is there a more efficient method to find a string in a text file then:
>for line in f:
> if 'string' in line:
> print 'FOUND'
>does "for line in f: " read a block of line to te memory or is it
>simply calls f.readline() many times?
If your file is sorted by some key in the data, you can build a very
fast binary search with mmap in Python.
More information about the Python-list