Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3443424
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:47:22+00:00 2026-05-18T08:47:22+00:00

I know how to extract a zip archive using Python, but how exactly do

  • 0

I know how to extract a zip archive using Python, but how exactly do I display the progress of that extraction in a percentage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:47:23+00:00Added an answer on May 18, 2026 at 8:47 am

    the extract method doesn’t provide a call back for this so one would have to use getinfo to get the e uncompressed size and then open the file read from it in blocks and write it to the place you want the file to go and update the percentage one would also have to restore the mtime if that is wanted an example:

    import zipfile
    z = zipfile.ZipFile(some_source)
    entry_info = z.getinfo(entry_name)
    i = z.open(entry_name)
    o = open(target_name, 'w')
    offset = 0
    while True:
        b = i.read(block_size)
        offset += len(b)
        set_percentage(float(offset)/float(entry_info.file_size) * 100.)
        if b == '':
            break
        o.write(b)
    i.close()
    o.close()
    set_attributes_from(entry_info)
    

    this extracts entry_name to target_name


    most of this is also done by shutil.copyfileobj but it doesn’t have a call back for progress either

    the source of the ZipFile.extract method calls _extract_member uses:

    source = self.open(member, pwd=pwd)
    target = file(targetpath, "wb")
    shutil.copyfileobj(source, target)
    source.close()
    target.close()
    

    where member has be converted from a name to a ZipInfo object by getinfo(member) if it wasn’t a ZipInfo object

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ZipArchive to extract zip files in an iOS application, but I
I would like to know how to extract values in a dictionary that appear
I know i can extract a file's icon using using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath))
I have an .ear file (an archive file like tar / zip) that has
Python, as far as know, does not allow modification of an archived file. That
I'm trying to extract an image from a zip archive and then write it
I need to unzip a .ZIP archive. I already know how to unzip it,
(Using XAMPP 1.7.7 with PHP 5.3.8) I know how to extract *.7z files with
I want to know how to extract all images in a webpage under a
I've got a list of spans, containing numbers. I know how to extract numbers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.