Using python 2.4 and the built-in ZipFile
library, I cannot read very large zip files (greater than 1 or 2 GB) because it wants to store the entire contents of the uncompressed file in memory. Is there another way to do this (either with a third-party library or some other hack), or must I "shell out" and unzip it that way (which isn't as cross-platform, obviously).
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
As of Python 2.6, you can use
ZipFile.open()
to open a file handle on a file, and copy contents efficiently to a target file of your choosing:This uses
shutil.copyfileobj()
to efficiently read data from the open zipfile object, copying it over to the output file.Here's an outline of decompression of large files.