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 7071137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:05+00:00 2026-05-28T05:39:05+00:00

I download a bz2 file using Python. Then I want to unpack the archive

  • 0

I download a bz2 file using Python. Then I want to unpack the archive using:

def unpack_file(dir, file):
    cwd = os.getcwd()
    os.chdir(dir)
    print "Unpacking file %s" % file
    cmd = "tar -jxf %s" % file
    print cmd
    os.system(cmd)
    os.chdir(cwd)

Unfortunately this ends with error:

bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
    Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Nieoczekiwany EOF w archiwum
tar: Nieoczekiwany EOF w archiwum
tar: Error is not recoverable: exiting now

However I can unpack the archive from the shell without any problem.

Do you have any ideas what I do wrong?

  • 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-28T05:39:06+00:00Added an answer on May 28, 2026 at 5:39 am

    For the record, python standard library ships with the tarfile module which automatically handles tar, tar.bz2, and tar.gz formats.

    Additionally, you can do nifty things like get file lists, extract subsets of files or directories or chunk the archive so that you process it in a streaming form (i.e. you don’t have to decompress the whole file then untar it.. it does everything in small chunks)

    import tarfile
    tar = tarfile.open("sample.tar.gz")
    tar.extractall()
    tar.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to download and parse webpage using python, but to access it I
I want to download this open source application, and they are using Git. What
I download one program that read file and then parse double values from String
I download the *.ics file successfully from the mail attachment by using intent-filter. I
download-dir: request-dir Print [downloading VStudio2008Express.iso ... ] url: http://go.microsoft.com/fwlink/?LinkId=104679 file-save: to-rebol-file rejoin [download-dir VStudio2008Express.iso]
Im looking for an example of how to decompress a bz2 file. I download
I download an image file from an FTP Server using FTPClient . My look
I've download gdb-6.5.bz2.tar. Untar this file. I write: LDFLAGS=-static ./configure but as a result
i download a kml file : <?xml version=1.0 encoding=UTF-8?> <kml xmlns=http://www.opengis.net/kml/2.2> <Document> <Style id=transGreenPoly>
def download(source_url): socket.setdefaulttimeout(10) agents = ['Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)','Mozilla/4.0 (compatible; MSIE

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.