[Tutor] Reading large bz2 Files

Norman Rieß norman at smash-net.org
Sat Feb 20 00:04:50 CET 2010


Am 19.02.2010 22:24, schrieb Lie Ryan:
> On 02/20/10 07:49, Norman Rieß wrote:
>   
>> Am 19.02.2010 21:42, schrieb Lie Ryan:
>>     
>>> On 02/19/10 23:42, Norman Rieß wrote:
>>>   
>>>       
>>>> Hello,
>>>>
>>>> i am trying to read a large bz2 file with this code:
>>>>
>>>> source_file = bz2.BZ2File(file, "r")
>>>> for line in source_file:
>>>>     print line.strip()
>>>>
>>>> But after 4311 lines, it stoppes without a errormessage. The bz2 file is
>>>> much bigger though.
>>>> How can i read the whole file line by line?
>>>>     
>>>>         
>>> Is the bz2 file an archive[1]?
>>>
>>> [1] archive: contains more than one file
>>>   
>>>       
>> No it is a single file. But how could i check for sure? Its extracts to
>> a single file...
>>     
> use "bzip2 -dc" or "bunzip2" instead of "bzcat" since bzcat concatenates
> its output file to a single file.
>
>
>   

Yes, it is a single file.


More information about the Tutor mailing list