By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

handling tar, gz and bz2 with python

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.