I have an iterator producing data, which I want to decompress.
import gzip
h = open('myfile.gz', 'rb')
data = iter(lambda: h.read(1024), b'')
gzip.decompress(data)
And I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/gzip.py", line 531, in decompress
with GzipFile(fileobj=io.BytesIO(data)) as f:
TypeError: a bytes-like object is required, not 'callable_iterator'
How can I decompress the iterator? The data can not be loaded into memory.