On Tue, Apr 23, 2013 at 2:00 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Also, you're searching the file system *for every line* in the input > file. Pull this outside of the loop and have it run once: > > if not os.path.exists(outdir): > os.makedirs(outdir) > > Likewise for opening and closing the output file, which you currently > open and close it for every line. It only needs to be opened and closed > once.
The outdir depends on the line, though. Hence my suggestion to retain the open files in a dictionary. ChrisA -- http://mail.python.org/mailman/listinfo/python-list