Is there an equivalent to gzip.open () for .7z files?

I often have to search for multiple .7z files (zipped with LZMA). I do not have enough memory to unpack them at the same time or to change the archive to .gz. At the moment, I am unpacking one, looking for what I need, deleting the extracted, unpacking the next one. I want to browse archives in the same way as with gzip:

f = gzip.open('archive.gz') for i in f: do stuff 

Is there a module / way to do this with .7z files?

+5
python windows archive 7zip
source share
1 answer

Python> = 3.3 has a built-in module: http://docs.python.org/3.3/library/lzma

And there is also a backport module on PyPI: https://pypi.python.org/pypi/backports.lzma

(If you are running Windows and do not want to compile it yourself, you can use the PyLZMA package from the Unofficial Windows binaries for Python ).

+5
source share

All Articles