'Extracting large files with zipfile
I'm trying to extract a zip file of 1.23 GB with zipFile
library. But it gives the following error:
compression type 9 (deflate64)
Here's my code:
zip_ref = zipfile.ZipFile(filepath, 'r')
zip_ref.extractall(newPath)
It gives error while trying to extract the contents.
Is there any way to unzip large zip files with Python?
Solution 1:[1]
This happens because that compression method is not implemented in the zipfile
module.
Some discussion about the issue is here: https://bugs.python.org/issue14313
The fix was to raise a NotImplementedError
instead of adding support for the compression method.
Suggested solutions:
- If possible, recompress the file using a standard deflate method.
- Use the
subprocess
module to invoke the systemunzip
command, asssuming it is installed on your OS (if it supports that compression method, I'm honestly not sure. I know that 7-zip supports the method.).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |