bearophileh...@lycos.com wrote:
oamram:
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).

Files can be iterated line-by-line, so this idiom:

for line in file: ...

will give you the lines, with newline. Once you have debugged that,
you can use the standard module glob (http://docs.python.org/library/
glob.html#module-glob ) to iterate on files.

[snip]
Or:

    for index, line in enumerate(my_file): ...

where index will give you the line number (starting from 0, so you'll
want lines 6 to 10). You can break out of the loop when you have all the
lines you want.

If you have more problems, show use the code you have written and we
may suggest improvements.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to