use fileinput to read a specific line

jo3c JO3chiang at gmail.com
Mon Jan 7 22:15:36 EST 2008


hi everybody
im a newbie in python
i need to read line 4 from a header file
using linecache will crash my computer due to memory loading, because
i am working on 2000 files each is 8mb

fileinput don't load the file into memory first
how do i use fileinput module to read a specific line from a file?

for line in fileinput.Fileinput('sample.txt')
????




More information about the Python-list mailing list