![]() ![]() We've got a plenty of libraries to choose from. It also has support for other features we know from tar utility - list of those is available at the top of above linked docs page. It can read and write gzip, bz2 and lzma files or archives. tarfile - as with zipfile above, you can probably guess that this module is used for working with tar archives.This module provides all the expected methods for creating, reading, writing or appending to ZIP files as well as classes and objects for easier manipulation of such files. ![]() zipfile - as the name suggests - allows us to work with zip archives in Python.shutils is a module we generally don't associate with compression and decompression, but it provides utility methods for working with archives and can be a convenient way for producing tar, gztar, zip, bztar or xztar archives.This module uses the already mentioned zlib compression algorithm and serves as an interface similar to the gzip and gunzip utilities. gzip is a utility most of us are familiar with.It can produce higher compression ratio than some older methods and is the algorithm behind the xz utility (more specifically LZMA2). lzma is both name of the algorithm and Python module.It also works only on individual files and therefore can't create archives. This algorithm is generally more effective than the deflate method, but might be slower. bz2 is a module that provides support for bzip2 compression.More about this library can be found on Wikipedia. So, by using this Python module, you're essentially using gzip compatible compression algorithm without theĬonvenient wrapper. zlib is a library and Python module that provides code for working with Deflate compression and decompression format which is used by zip, gzip and many others.So, let's first take a look at each of them and see why you might want to use them: All The FormatsĪs mentioned above, Python has library for (almost) every tool/format imaginable. So, to help you navigate through all the available options, we will in this article explore all of these modules and learn how to compress, decompress, verify, test and secure our archives of all kinds of formats with help of Python's standard library. With all these options, deciding what might be the right tool for the task at hand might not be so obvious, though. Whether it's basics like tar and zip, specific tools or formats such as gzip and bz2 or even more exotic formats like lzma, Python has it all. Print "Usage: '%s filename'" % sys.Python standard library provides great modules and tools for pretty much any task you can think of and modules for working with compressed files are no exception. Print "Not a tar.gz file: '%s '" % sys.argv Here’s a simple small python script to untar a tar or tar.gz file in windows without any download, provided you have python installed!!Ĭreated on Thu Feb 20 06:59:20 Sukhbinder Singh This exploration brought me to the standard python module tarfile. Reluctant to install one more software in my virtual box window, I was looking for a download free solution. To unzip a tar or tar.gz format in windows, a 3rd party download like winrar is required. Users of Mac, Linux and Unix operating systems have it easy.Īlong with the omnipresent zip, they do have ready-to-use tools for most compression formats built right into the operating system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |