On 29/09/11 15:22, lina wrote:
I want to read a bunch of *.doc file in present working directory,
What format are the doc files?
If they are word processor files they may well be in binary format so
you will need to either decode them (using struct?) or find a module
that can read them, or a tool that can convert them to something you can
read.
Once you figure out how to read a single file reading multiple files can
be done in a number of ways including using os.walk() and a
for loop (or the fileinput module).
for root,dirs,files in os.walk(path):
docs = [f for f in files if f.endswith '.doc'] # or use glob
for line in fileinput.input(docs):
#process line
But the hardest bit is likely going to be the reading of the files if
they are not plain text.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor