Skip to content

Instantly share code, notes, and snippets.

@miodeqqq
Created December 8, 2016 20:14
Show Gist options
  • Save miodeqqq/3de707c33306ae3d6e0cf9a3c13f92b1 to your computer and use it in GitHub Desktop.
Save miodeqqq/3de707c33306ae3d6e0cf9a3c13f92b1 to your computer and use it in GitHub Desktop.
Python function to check if *.tar.gz file is empty.
def is_nonempty_gz_file(self, tarfile):
with open(tarfile, 'rb') as f:
try:
file_content = f.read(1)
return len(file_content) > 0
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment