GZip: Python - How to get the file name of a particular line using gzip.open -


i have '.tgz' file, i'm reading content of '.tgz' file using gzip.open. fastest way file name of particular line?

with gzip.open('sample.tgz','r') fin:     line in fin:         error = checkforerror(line)         if error:             # file name in particular error line present         else:             pass 

this functions quite how useful is, anyone's guess.
check https://en.wikipedia.org/wiki/tar_%28computing%29#header header format.

import gzip fin = gzip.open("test.txt.tar","r") in fin:     if "ustar" in i:         fname,b = i.split("0",1)         print fname     else:         print fin.close() 

note: python 2.7.6 on linux, assuming archive created tar czvf


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -