I don\'t want to use OS commands as that makes it is OS dependent.
This is available in tarfile, tarfile.is_tarfile(filename), to check if
tarfile
tarfile.is_tarfile(filename)
import gzip with gzip.open("pCSV.csv.gz", 'r') as f: f.seek(3) couterA = f.tell() f.seek(2,0) counterB = f.tell() if(couterA > counterB): print "NOT EMPTY" else: print "EMPTY"
This should do it without reading the file.