for ex abc.tar.gz has
abc/file1.txt
abc/file2.txt
abc/abc1/file3.txt
abc/abc2/file4.txt
i need to read/display the contents of file3.txt without extracting the file.
Thanks for any input.
for ex abc.tar.gz has
abc/file1.txt
abc/file2.txt
abc/abc1/file3.txt
abc/abc2/file4.txt
i need to read/display the contents of file3.txt without extracting the file.
Thanks for any input.
import tarfile
spam = tarfile.open( "abc.tar.gz" )
if "abc/abc1/file3.txt" in spam.getnames():
with spam.extractfile( "abc/abc1/file3.txt" ) as ham:
print ham.read()
See tarfile.