Python Forum
Need help to read a gzip stream...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help to read a gzip stream...
#1
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...
Reply
#2
import gzip
with gzip.open('file.txt.gz', 'rb') as f:
    file_content = f.read()
Reply
#3
heiner, why are you answering posts from 2017?
Reply
#4
Because I am bored.
I hope this is allowed.
Reply
#5
Sure it is.
Reply
#6
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Microphone stream manipulation Talking2442 1 2,676 Nov-19-2023, 02:08 PM
Last Post: palumanic
  EEG stream data with mne and brainfolw PaulC 0 461 Aug-22-2023, 03:17 AM
Last Post: PaulC
  python gzip all files from a folder mg24 3 3,807 Oct-28-2022, 03:59 PM
Last Post: mg24
  Decoding a serial stream AKGentile1963 7 8,338 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Best Video Quality And Stream Harshil 2 2,188 Aug-19-2020, 09:03 AM
Last Post: Harshil
  stream audio from pc to pc floatingshed 2 1,929 Sep-16-2019, 03:45 PM
Last Post: floatingshed
  pi camera stream is upside down delta1071 3 5,678 Sep-11-2019, 11:35 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020