remotezip2 is a Python library that provides efficient access to individual files within a remote ZIP archive without requiring the full download of the entire archive. It functions by leveraging HTTP Range requests, making it suitable for scenarios where only specific contents of large remote ZIP files are needed. As a fork of the original `python-remotezip`, it aims for continued maintenance and responsiveness. The current version is 0.0.2, with a relatively slow release cadence, having received a maintenance update in late 2024 since its initial release.
pip install remotezip2Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to list the contents of a remote ZIP file and extract a specific file using `remotezip2`. It initializes `RemoteZip` with a URL and then uses `namelist()` to see the files and `open()` to read the content of a specific member. The `REMOTE_ZIP_URL` environment variable can be used to specify a different ZIP file for testing.
Prefer `extract()` or `open()` for individual files. Only use `extractall()` if the full archive download is acceptable.
Avoid negative seeks when reading individual remote files. If complex random access is required, consider extracting the file locally first.
Verify that the server hosting the ZIP file supports HTTP Range requests. If not, consider a different approach or server configuration.
Ensure that any remote ZIP files you intend to process with `remotezip2` are well-formed and adhere to modern ZIP file standards to avoid parsing issues, especially those related to central directory and local file header consistency.