473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

zlib.decompress cannot, gunzip can

I have a string which I try to decompress:

body = zlib.decompress(body)

but I get

zlib.error: Error -3 while decompressing data: incorrect header check

However, I can write the string to a file and run gunzip with the
expected results:

f = open('/tmp/bd.gz', 'w')
f.write(body)
f.close
....
$ gunzip bd.gz
$ less bd

What should I do to decompress it in Python?

Regards, Enrique

Jul 18 '05 #1
2 11369
On 2005-03-01, en***@online.no <en***@online.no> wrote:
I have a string which I try to decompress:

body = zlib.decompress(body)

but I get

zlib.error: Error -3 while decompressing data: incorrect header check

However, I can write the string to a file and run gunzip with the
expected results:


gzip files have a header preceding the zlib stream. Try the gzip module.
Jul 18 '05 #2
Thanks, now the code is

from cStringIO import StringIO
from gzip import GzipFile
...
body = GzipFile('','r',0,StringIO(body)).read()

Regards, Enrique

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Greg Bakken | last post by:
I am writing a python program that recieves 'compressed and encoded' strings from another piece of software. I can successfully uncompress and decode the strings via import base64, zlib def...
0
by: Tony | last post by:
Hello, Any assistance would be appreciated: As the subject suggests I am trying to gunzip files using the Compress::Zlib module. The following is basically the code that I am working with: ...
2
by: Paul Watson | last post by:
Traceback (most recent call last): File "<string>", line 20, in ? File "c:\Python24\lib\encodings\zlib_codec.py", line 43, in zlib_decode output = zlib.decompress(input) zlib.error: Error -5...
1
by: Dennis Powell | last post by:
Does anyone have a successful implementaion of the zlib.dll in VB. Net they can show me. I'm writting a class encaplsulating zlib functionality and I keep getting a System.NullReferenceException...
0
by: Jan Prochazka | last post by:
Hi, I need to decompress zip archive. I wrote a parser of zip file, i obtain the compressed data, but when i call zlib.decompress(data) on them, it throws this error: decbuf =...
0
by: Jan Prochazka | last post by:
Hi, I need to decompress zip archive. I wrote a parser of zip file, i obtain the compressed data, but when i call zlib.decompress(data) on them, it throws this error: decbuf =...
1
by: nagrik | last post by:
Hello Group, I am writing a http client and reading a web page from the server. The page can be compressed in any of the format namely; gzip or deflate or compress. My client reads the page...
2
by: flebber | last post by:
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
2
by: Hyunchul Kim | last post by:
Hi, all How can .Z file be decompressed? According to python library reference, .Z file might not be supported by python, yet. Best, Hyunchul Kim
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.