Created
March 30, 2020 22:48
-
-
Save dustyfresh/28b02389e3b8465fa08fcb95db703796 to your computer and use it in GitHub Desktop.
read gzipped data from a remote file as a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import gzip | |
import requests | |
data = requests.get('https://url/file.txt.gz', stream=True) | |
in_ = io.BytesIO() | |
in_.write(data.content) | |
in_.seek(0) | |
gunzipped_bytes_obj = gzip.GzipFile(fileobj=in_, mode='rb').read() | |
data = gunzipped_bytes_obj.decode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment