python noob, multiple file i/o

hiro NunezD at gmail.com
Thu Mar 15 23:56:02 EDT 2007


Hi there,

I'm very new to python, the problem I need to solve is whats the "best/
simplest/cleanest" way to read in multiple files (ascii), do stuff to
them, and write them out(ascii).

--
import os

filePath = ('O:/spam/eggs/')
for file in os.listdir(filePath):   #straight from docs
    # iterate the function through all the files in the directory
    # write results to separate files  <- this is where I'm mostly
stuck.

--
For clarity's sake, the file naming conventions for the files I'm
reading from are file.1.txt -> file.nth.txt

It's been a long day, i'm at my wits end, so I apologize in advance if
I'm not making much sense here.
syntax would also be great if you can share some recipes.

Thanks in advance.

h.




More information about the Python-list mailing list