.tar.gz open files code example
Example 1: tar.gz files
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Example 2: read tar.gz file python
The docs tell us that None is returned by extractfile() if the member is a not a regular file or link.
One possible solution is to skip over the None results:
tar = tarfile.open("filename.tar.gz", "r:gz")
for member in tar.getmembers():
f = tar.extractfile(member)
if f is not None:
content = f.read()