我正在尝试压缩大小为300GB的虚拟机文件。在
每次python脚本被终止时,因为
gzip
模块超过30GB(虚拟内存)。在
有没有办法用python实现大文件(300GB到64TB)压缩?在
def gzipFile(fileName):
startTime = time.time()
with open(fileName,'rb') as fileHandle:
compressedFileName = "%s-1.gz" % fileName
with gzip.open(compressedFileName, 'wb') as compressedFH:
compressedFH.writelines(fileHandle)
finalTime = time.time() - startTime
print("gzipFile=%s fileName=%s" % (finalTime,compressFileName))
从外部运行,最简单的方式,可能最快。在
逐行写入文件
fileHandle
,即将其拆分为由\n
字符分隔的块。在虽然这个字符很有可能在二进制文件中不时出现,但这并不能保证。在
这样做可能更好
^{pr2}$或者,正如tqzf在评论中所写
相关问题 更多 >
编程相关推荐