end of file for large files

Bob Horvath bob at horvath.com
Thu Nov 16 00:25:54 EST 2000


doyen at mediaone.net wrote:

> I'm very new at this, but after doing a
>
> try:
>     foile = open( filename, 'r')
> except:
>     print  'error '
>     return
>
> lines = file.readlines()
> for line in lines:
>     blah
>
>  I changed to this which I believe reads in a single line at a time
>
> for line n fileinput.input(filename)
>     lctr = lctr + 1
>     processlines(line)
>
> I seems to work well for megabyte files, but I'm not sure what you mean
> by 'large'
> Also I'm not sure it would work for binary files.
>
> You should probably follow the advice of somebody who knows more about
> what they're talking about though :-)
>

I am trying to help someone else out, so I don't have complete details,
but the description of the file was a file that was essentially one very
long (many MB) line that also included some unprintable characters.  That
makes me think anything that relies on readline will potentially fail.





More information about the Python-list mailing list