[英]Get distance read into a bz2 compressed file in python
我有一個很大的(很多GB).bz2壓縮文件,我正在使用python的bz2.open()函數讀取該文件。 我想提供有關剩余多少文件可讀取的狀態更新。 我可以從文件系統中獲取文件大小,以及使用bz2_filehandle.tell()到目前為止讀取的未壓縮字節數,但是如何獲取到目前為止讀取的壓縮字節數?
多虧了@ ignacio-vazquez-abrams,我才得以解決:
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())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.