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
  How do I stream and record at the same time with arducam? traderjoe 0 1,721 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  EEG stream data with mne and brainfolw PaulC 0 1,361 Aug-22-2023, 03:17 AM
Last Post: PaulC
  python gzip all files from a folder mg24 3 8,389 Oct-28-2022, 03:59 PM
Last Post: mg24
  Create RTSP stream from camera? korenron 1 5,332 Jan-04-2022, 10:38 AM
Last Post: Larz60+
  Stream via socket with multiple clients principemestizo 0 3,751 Nov-01-2021, 06:25 PM
Last Post: principemestizo
  Decoding a serial stream AKGentile1963 7 15,985 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Microphone stream manipulation Talking2442 0 5,714 Jan-07-2021, 07:36 PM
Last Post: Talking2442
  Best Video Quality And Stream Harshil 2 3,726 Aug-19-2020, 09:03 AM
Last Post: Harshil
  stream audio from pc to pc floatingshed 2 3,251 Sep-16-2019, 03:45 PM
Last Post: floatingshed
  pi camera stream is upside down delta1071 3 8,133 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