loop though textfiles
Max Haas
Max.Haas at unibas.ch
Mon May 14 11:18:38 EDT 2001
Martin Johansson wrote:
>
> Hi!
> How can I do if I want to do a searchmethon on several textfiles? Can I use
> fileinput and how should I do?
> It must be some kind of loop.
Perhaps you can try something like:
the_dir = give your directory with the files you're
interested in
MyDir = os.listdir(the_dir) # make a list of all these files
# then your loop:
for file_name in MyDir: #file_name is the name of the
current file
do text search here
Regards
Max
More information about the Python-list
mailing list