Created
December 12, 2018 14:52
-
-
Save vsoch/e06a0dc2eb43a72b38db5ee0b5cdd555 to your computer and use it in GitHub Desktop.
Neato! Extract a .tar.gz from a .tar, and read the file content, all in memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import tarfile | |
input_tar = sys.argv[1] | |
tar = tarfile.open(input_tar, 'r') | |
for member in tar: | |
print("Extracting %s" % member.name) | |
subtar = tarfile.open(mode='r|gz', fileobj=tar.extractfile(member)) | |
for submember in subtar: | |
print("Found %s!" % submember.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment