Re: Process multiple files

2008-04-14 Thread Duncan Booth
"Doran, Harold" <[EMAIL PROTECTED]> wrote: > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt f

Re: Process multiple files

2008-04-14 Thread Tim Chase
> new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and

Re: Process multiple files

2008-04-14 Thread Robert Bossy
Doran, Harold wrote: > Say I have multiple text files in a single directory, for illustration > they are called "spam.txt" and "eggs.txt". All of these text files are > organized in exactly the same way. I have written a program that parses > each file one at a time. In other words, I need to run m

Re: Process multiple files

2008-04-14 Thread Paul Anton Letnes
Funny, I'm just doing exactly this: import os def main(): dataFolder = 'data/' fileList = os.listdir(dataFolder) for file in fileList: inFile = open(dataFolder + file, 'r') print 'read inFile & do something useful here' Clear as an... egg?