Reading a large bz2 textfile exits early

Norman Rieß norman at smash-net.org
Mon Feb 22 01:49:51 EST 2010


Am 02/21/10 22:09, schrieb Dennis Lee Bieber:
> On Sat, 20 Feb 2010 23:12:50 +0100, Norman Rieß<norman at smash-net.org>
> declaimed the following in comp.lang.python:
>
>    
>> Hello,
>>
>> i am trying to read a large bz2 compressed textfile using the bz2 module.
>> The file is 1717362770 lines long and 8GB large.
>> Using this code
>>
>> source_file = bz2.BZ2File(file, "r")
>>      for line in source_file:
>>      print line.strip()
>>
>>      print "Exiting"
>>      print "I used file: " + file
>>
>> the loop exits cleanly after 4311 lines in midline and the prints are
>> executed.
>> This happened on two different boxes runnig different brands of linux.
>> Is there something i miss or should be done differently?
>>
>>      
> 	Please verify your indentation! What you posted above is invalid in
> many ways.
>    
I am sorry, the indentation suffered from pasting.

This is the actual code:

source_file = bz2.BZ2File(file, "r")
for line in source_file:
     print line.strip()

print "Exiting"
print "I used file: " + file






More information about the Python-list mailing list