Introduction
Public datasets and software resources are frequently distributed as ZIP archives, and
downloading-then-unzipping is boilerplate that shouldn't need to be rewritten in every
pipeline. GetZipFile answers "how do I get everything in this remote archive onto
disk, and what's actually in it?" — downloading in memory (no temp file), optionally
extracting, and optionally listing contents for a quick sanity check before you
process anything. Reach for it when automating data collection from archives, whether
that's a government open-data portal or an internal file repository.
Teaching Note
This is particularly useful for:
- Downloading public datasets distributed as ZIP archives
- Automating data collection pipelines that require compressed files
- Retrieving software packages, documentation, or resources from web servers
- Batch processing of archived data from APIs or file repositories
- Setting up project dependencies or assets from remote sources
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
urlrequired | | — | The URL of the ZIP file to download. Must be a valid HTTP/HTTPS URL pointing to a ZIP archive. |
path_to_save_folderrequired | | — | The directory path where the ZIP file contents will be extracted. The directory will be created if it doesn't exist (when using extractall). |
unzip | | True | If True, extracts all files from the ZIP archive to the specified folder. If False, only downloads and inspects the archive without extraction. |
print_contents | | True | If True, prints a list of all files contained in the ZIP archive to the console. Useful for verification and debugging. |
Example
python
from analysistoolbox.data_collection import GetZipFile
# Download and extract a ZIP file, printing its contents
GetZipFile(
url='https://example.com/data/dataset.zip',
path_to_save_folder='./data',
unzip=True,
print_contents=True
)