[Tutor] extracting lines in large file

Alan Gauld alan.gauld at btinternet.com
Tue Jun 23 00:40:38 CEST 2009

"Bryan Fodness" <bryan.fodness at gmail.com> wrote 

>I am trying to output all the lines that start with a specific word.
> It is a large output file (~14 Mb), but nothing that I thought would
> be a problem.

Shouldn't be, you are processing one line at a time!

> for line in open('output.new'):
>    i_line = line.split()
>    if i_line:
>        if i_line[0] == "intrinsic":
>            print i_line
> It does not get all of the lines, it stops at line 130323.  There are

Sounds like it has an EOF character in it, try opening in binary 
mode and see what happens... It could cause other problems 
if there really is binary data in there but it might just work...

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list