distinction between unzipping bytes and unzipping a file
ryandw at gmail.com
Fri Jan 9 21:32:28 CET 2009
On Jan 9, 3:15 pm, Steve Holden <st... at holdenweb.com> wrote:
> webcomm wrote:
> > Hi,
> > In python, is there a distinction between unzipping bytes and
> > unzipping a binary file to which those bytes have been written?
> > The following code is, I think, an example of writing bytes to a file
> > and then unzipping...
> > decoded = base64.b64decode(datum)
> > #datum is a base64 encoded string of data downloaded from a web
> > service
> > f = open('data.zip', 'wb')
> > f.write(decoded)
> > f.close()
> > x = zipfile.ZipFile('data.zip', 'r')
> > After looking at the preceding code, the provider of the web service
> > gave me this advice...
> > "Instead of trying to create a file, take the unzipped bytes and get a
> > Unicode string of text from it."
> Not terribly useful advice, but one presumes he she or it was trying to
> be helpful.
> > If so, I'm not sure how to do what he's suggesting, or if it's really
> > different from what I've done.
> Well, what you have done appears pretty wrong to me, but let's take a
> look. What's datum? You appear to be treating it as base64-encoded data;
> is that correct? Have you examined it?
It's data that has been compressed then base64 encoded by the web
service. I'm supposed to download it, then decode, then unzip. They
provide a C# example of how to do this on page 13 of
If you have a minute, see also this thread...
More information about the Python-list