Decompressing a .bz2 file in Python

前端 未结 3 1751
野趣味
野趣味 2021-02-09 17:51

So, this is a seemingly simple question, but I\'m apparently very very dull. I have a little script that downloads all the .bz2 files from a webpage, but for some reason the dec

3条回答
  •  天命终不由人
    2021-02-09 18:00

    This was very helpful. 44 of 2300 files gave an end of file missing error, on Windows open. Adding the b(inary) flag to open fixed the problem.

    for line in bz2.BZ2File(filename, 'rb', 10000000) :
    

    works well. (the 10M is the buffering size that works well with the large files involved)

    Thanks!

提交回复
热议问题