473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

handling tar, gz and bz2 with python

Is there a module for unpacking tar files in python? how about bzip2 and
gzips? I know I can use the gzip module for gzips but is there anything
that can detect what format a file is in and decopress and unpack it
using the other methods?

thanks
-Matthew
Jul 19 '05 #1
1 2615
Matthew Thorley wrote:
Is there a module for unpacking tar files in python?
import tarfile
help(tarfile)

...
| open(cls, name=None, mode='r', fileobj=None, bufsize=10240) from __built
in__.type
| Open a tar archive for reading, writing or appending. Return
| an appropriate TarFile class.
|
| mode:
| 'r' open for reading with transparent compression
| 'r:' open for reading exclusively uncompressed
| 'r:gz' open for reading with gzip compression
| 'r:bz2' open for reading with bzip2 compression
| 'a' or 'a:' open for appending
| 'w' or 'w:' open for writing without compression
| 'w:gz' open for writing with gzip compression
| 'w:bz2' open for writing with bzip2 compression
| 'r|' open an uncompressed stream of tar blocks for reading
| 'r|gz' open a gzip compressed stream of tar blocks
| 'r|bz2' open a bzip2 compressed stream of tar blocks
| 'w|' open an uncompressed stream for writing
| 'w|gz' open a gzip compressed stream for writing
| 'w|bz2' open a bzip2 compressed stream for writing
|
| taropen(cls, name, mode='r', fileobj=None) from __builtin__.type
| Open uncompressed tar archive name for reading or writing.
...
how about bzip2 and gzips? I know I can use the gzip module for gzips
but is there anything that can detect what format a file is in and decopress
and unpack it using the other methods?


see above.

</F>

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Williams | last post by:
Hi people Part of the reason I have started using Python (experience: 3 days) is that I recognise the potential benefits in using it compared to writing C/C++ code. In particular, there are a...
3
by: alastair | last post by:
Hi, I am trying to use Python to do the following: - read in an image in geoTIFF format - extract the tags from the file - do something interesting with the tags I've read about the Python...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
11
by: Josh | last post by:
Hi, I am having a problem with Python. I am new to Python as a programming language, but I do have experience in other languages. I am experiencing strange problems with File handling and wonder...
3
by: Gonçalo Rodrigues | last post by:
Hi all, I've got two somewhat general questions related to exception handling in C++. My usual programming language is the lovely and flexible Python, but for various reasons, including the need...
22
by: Andy McDonagh | last post by:
Dear python experts, I am new to python and this site, so I apologize if this is off topic (i.e. is it a SciPy question?). I will try to demonstrate my problem below:...
2
by: Petr Jakes | last post by:
I am a little bit confused by all possibilities for exceptions handling in Python (probably because I am not skilled enough??) I did try to search trough this list and reading Python tutorial about...
8
by: Adil Akram | last post by:
There are situations where you want to retry/rerun the same code again (if user wants) for unlimited times for a particular exception thrown. For example in situations like there's no CD in the...
17
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML...
35
by: eliben | last post by:
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.