Gzip - gunzip using zlib

F

flebber

Hi Can anyone show me a working example of how to use gzip to
decompress a file. I have read the docs at python.org and had many
goes at it but just can't get it to work.

Cheers

flebber
 
P

Paul Rubin

flebber said:
Hi Can anyone show me a working example of how to use gzip to
decompress a file. I have read the docs at python.org and had many
goes at it but just can't get it to work.

Untested in this instance, but this is how I usually do it:

import gzip

z = gzip.open('parrot.gz')
for line in z:
...
 
S

Stefan Behnel

flebber said:
Hi Can anyone show me a working example of how to use gzip to
decompress a file. I have read the docs at python.org and had many
goes at it but just can't get it to work.

According to your other post, you are trying to open a ZIP archive using gzip.
Use the zipfile module instead.

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top