Re: distinction between unzipping bytes and unzipping a file

2009-01-10 Thread John Machin
On Jan 11, 6:15 am, webcomm wrote: > On Jan 9, 6:07 pm, John Machin wrote: > > > Yup, it looks like it's encoded in utf_16_le, i.e. no BOM as > > God^H^H^HGates intended: > > > >>> buff = open('data', 'rb').read() > > >>> buff[:100] > > > '<\x00R\x00e\x00g\x00i\x00s\x00t\x00r\x00a\x00t\x00i\x00o\

Re: distinction between unzipping bytes and unzipping a file

2009-01-10 Thread webcomm
On Jan 9, 6:07 pm, John Machin wrote: > Yup, it looks like it's encoded in utf_16_le, i.e. no BOM as > God^H^H^HGates intended: > > >>> buff = open('data', 'rb').read() > >>> buff[:100] > > '<\x00R\x00e\x00g\x00i\x00s\x00t\x00r\x00a\x00t\x00i\x00o\x00n\x00> > \x00<\x00B\x0 > 0a\x00l\x00a\x00n\x00c

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread John Machin
On Jan 10, 8:56 am, webcomm wrote: > On Jan 9, 4:12 pm, "Chris Mellon" wrote: > > > It would really help if you could post a sample file somewhere. > > Here's a sample with some dummy data from the web > service:http://webcomm.webfactional.com/htdocs/data.zip > > That's the zip created in this l

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 4:12 pm, "Chris Mellon" wrote: > It would really help if you could post a sample file somewhere. Here's a sample with some dummy data from the web service: http://webcomm.webfactional.com/htdocs/data.zip That's the zip created in this line of my code... f = open('data.zip', 'wb') If I

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Chris Mellon
On Fri, Jan 9, 2009 at 3:08 PM, Chris Mellon wrote: > On Fri, Jan 9, 2009 at 2:32 PM, webcomm wrote: >> On Jan 9, 3:15 pm, Steve Holden wrote: >>> webcomm wrote: >>> > Hi, >>> > In python, is there a distinction between unzipping bytes and >>> > unzipping a binary file to which those bytes have

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Chris Mellon
On Fri, Jan 9, 2009 at 2:32 PM, webcomm wrote: > On Jan 9, 3:15 pm, Steve Holden 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 exa

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 3:15 pm, Steve Holden 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..

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread MRAB
webcomm wrote: Hi, In python, is there a distinction between unzipping bytes and unzipping a binary file to which those bytes have been written? Python's zipfile module can only read and write zip files; it can't compress or decompress data as a bytestring. The following code is, I think, an

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Steve Holden
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 i

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 2:49 pm, webcomm wrote: > 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') Sorry, that code is not what I mean to paste. This