Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Python package similar to Perl's Archive::Extract?

I'm looking for a package that will automatically detect the type of and extract an archive (zip, tar.gz, etc). In Perl, this is easy - in Python, I can't find any simple package/class to do it...

like image 339
Loki Avatar asked Feb 02 '26 04:02

Loki


2 Answers

Riding off of Mark Byers' response, perhaps you can tie all of these together with mimetypes (also from the standard library). You could identify the type of file, and process it accordingly. The world needs a Python version of Archive::Extract, and we want you to write it!

like image 83
jathanism Avatar answered Feb 04 '26 00:02

jathanism


In Python you can use:

  • zipfile
  • tarfile - Note: Tarfile can also handle bz2ed and gzipped tar files.
  • bz2
  • gzip

I'm not aware of any wrapper that can choose the right format automatically. If it exists it doesn't seem to be mentioned in the documentation for any of the above modules.

like image 21
Mark Byers Avatar answered Feb 03 '26 22:02

Mark Byers