Need help to read a gzip stream... - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Need help to read a gzip stream... (/thread-6033.html) |
Need help to read a gzip stream... - pythonchakri - Nov-03-2017 Following code errors, and I have tried every mechanism that is available on google search. Still could not get the stream to uncompress without errors. But the same file can be read in both Java and Scala. orig_file_desc = GzipFile(mode='r', fileobj=(io.StringIO(fileResponse.text))) csvReader = csv.reader((orig_file_desc)) print("two") for csvReaderRow in csvReader: print(', '.join(csvReaderRow)) And error for the above is "AttributeError: 'str' object has no attribute 'read'" And various other errors for each other methods to get the job done. I used, zlib too. Help is much much appreciated... RE: Need help to read a gzip stream... - heiner55 - Jun-06-2019 import gzip with gzip.open('file.txt.gz', 'rb') as f: file_content = f.read() RE: Need help to read a gzip stream... - Larz60+ - Jun-06-2019 heiner, why are you answering posts from 2017? RE: Need help to read a gzip stream... - heiner55 - Jun-06-2019 Because I am bored. I hope this is allowed. RE: Need help to read a gzip stream... - Larz60+ - Jun-06-2019 Sure it is. RE: Need help to read a gzip stream... - heiner55 - Jun-07-2019 Thanks |