471,056 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,056 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 2516
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.

Similar topics

1 post views Thread by Dan Williams | last post: by
3 posts views Thread by alastair | last post: by
9 posts views Thread by Hans-Joachim Widmaier | last post: by
11 posts views Thread by Josh | last post: by
3 posts views Thread by Gonçalo Rodrigues | last post: by
22 posts views Thread by Andy McDonagh | last post: by
8 posts views Thread by Adil Akram | last post: by
17 posts views Thread by frederic.pica | last post: by
35 posts views Thread by eliben | last post: by
reply views Thread by leo001 | last post: by

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.