Python function to stream unzip all the files in a ZIP archive, without loading the entire ZIP file into memory or any of its uncompressed files
Project description
stream-unzip

Python function to stream unzip all the files in a ZIP archive, without loading the entire ZIP file into memory or any of its uncompressed files.
Installation
pip install stream-unzip
Usage
A single function is exposed, stream_unzip, that takes a single argument: an iterable that should yield the bytes of a ZIP file. It returns an iterable, where each yielded item is a tuple of the file name, file size, and another iterable itself yielding the unzipped bytes of that file.
from stream_unzip import stream_unzip
import httpx
def zipped_chunks():
# Any iterable that yields a zip file
with httpx.stream('GET', 'https://www.example.com/my.zip') as r:
yield from r.iter_bytes()
for file_name, file_size, unzipped_chunks in stream_unzip(zipped_chunks()):
for chunk in unzipped_chunks:
print(chunk)
The file name and file size are extracted as reported from the file. If you don't trust the creator of the ZIP file, these should be treated as untrusted input.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stream-unzip-0.0.1.tar.gz.
File metadata
- Download URL: stream-unzip-0.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d033afe2e5285a02f730385ac57d51cafaed497ded5747bc6d19cb70311951c6
|
|
| MD5 |
20b91d4e02ae813ec605d4bed45659a9
|
|
| BLAKE2b-256 |
906a44c490a09cbaa1b7dea1922507d0a8b7f41ea5d9fda48cfcb416fe4d055f
|
File details
Details for the file stream_unzip-0.0.1-py3-none-any.whl.
File metadata
- Download URL: stream_unzip-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44a9aa7e9983bb0ed28aea4526a11c899c97b4662f5f4daed8bd8b85130965b2
|
|
| MD5 |
4ca45cf73e7125773f2bc2706ea5bbf6
|
|
| BLAKE2b-256 |
245d44ef73e9badab406c3e156047ddb38e71ca105c42dd6ee8099850a489fe1
|