Skip to content

Instantly share code, notes, and snippets.

@dwcoates
Created February 14, 2017 06:19
Show Gist options
  • Select an option

  • Save dwcoates/932ed3cfd514673ff47447c86c1a3537 to your computer and use it in GitHub Desktop.

Select an option

Save dwcoates/932ed3cfd514673ff47447c86c1a3537 to your computer and use it in GitHub Desktop.
Second snippet for you
# option 1
import gzip
fp = gzip.open('foo.gz')
x = json.load(fp.read())
# option 2
gzip.open('file.gz', 'rt', encoding='utf-8')
# option 3
import codecs
zf = gzip.open(fname, 'rb')
reader = codecs.getreader("utf-8")
contents = reader(zf)
for line in contents:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment