我正在尝试解压缩一个大的gzip文件(2GB)。如果我使用read()函数,由于这么多数据,它会冻结我的计算机。所以,看看stackoverflow的另一个答案,我使用了逐行读取gzip文件的方法
inF = gzip.open(compressed_file_name, 'rb')
outF = open(outfilename, 'wb')
for line in inF:
outF.write(line)
inF.close()
outF.close()
但是,在文件末尾,我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in download_latest_file
File "/usr/lib/python2.7/gzip.py", line 455, in readline
c = self.read(readsize)
File "/usr/lib/python2.7/gzip.py", line 261, in read
self._read(readsize)
File "/usr/lib/python2.7/gzip.py", line 308, in _read
self._read_eof()
File "/usr/lib/python2.7/gzip.py", line 347, in _read_eof
hex(self.crc)))
IOError: CRC check failed 0x3b5a517c != 0x643d9301L
我的python版本是2.7.6