I need to unzip a .ZIP archive. I already know how to unzip it, but it is a huge file and takes some time to extract. How would I print the percentage complete for the extraction? I would like something like this:
Extracting File
1% Complete
2% Complete
etc, etc
You can just monitor the progress of each file being extracted with tqdm()
:
from zipfile import ZipFile
from tqdm import tqdm
# Open your .zip file
with ZipFile(file=path) as zip_file:
# Loop over each file
for file in tqdm(iterable=zip_file.namelist(), total=len(zip_file.namelist())):
# Extract each file to another directory
# If you want to extract to current working directory, don't specify path
zip_file.extract(member=file, path=directory)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With