0

I've got a big (many GB) .bz2 compressed file, which I am reading in using python's bz2.open() function. I want to provide a status update about how much of the file is left to read. I can get the file size from the file system, and the number of uncompressed bytes read so far using bz2_filehandle.tell(), but how can I get the number of compressed bytes read so far?

user2667066
  • 1,867
  • 2
  • 19
  • 30

1 Answers1

0

Thanks to @ignacio-vazquez-abrams I worked it out:

with open("path/to/file.bz2", 'rb') as compressed_file:
 with bz2.open(file, 'rb') as uncompressed_file:
  for l in uncompressed_file:
   print(compressed_file.tell(), uncompressed_file.tell())
user2667066
  • 1,867
  • 2
  • 19
  • 30