On Feb 17, 11:03 am, oamram <[email protected]> wrote: > Hi All, > new to python. i have a directory with about 50 text file and i need to > iterate through them and get > line 7 to 11 from each file and write those lines into another file(one file > that will contain all lines). >
import glob
file("output.txt","w").write('\n'.join( "".join(f.readlines()
[7:11+1]) ) for f in glob.glob("targetdir/*.txt"))
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
