On Jan 8, 2:08 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > Given that the OP is talking 2000 files to be processed, I think I'd > > recommend explicit open() and close() calls to avoid having lots of I/O > > structures floating around... > > Good point. I didn't think of that. It could also be done as follows: > > for fileN in files: > > lnum = 0 # line number > input = file(fileN) > > for line in input: > lnum += 1 > if lnum >= 4: break > > input.close() > > # do something with "line" > > Six of one or half a dozen of the other, I suppose.
this is what i did using glob import glob for files in glob.glob('/*.txt'): x = open(files) x.readline() x.readline() x.readline() y = x.readline() # do something with y x.close() -- http://mail.python.org/mailman/listinfo/python-list