trying to gzip uncompress a StringIO
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue May 22 17:48:13 EDT 2007
En Tue, 22 May 2007 14:22:25 -0300, <bob at snee.com> escribió:
> I'm using the code below to read the zipped, base64 encoded WMF file
> saved in an XML file with "Save as XML" from MS Word. As the "At this
> point" comment shows, I know that the base64 decoding is going fine,
> but unzipping from the decodedVersion StringIO object isn't getting me
> anything, because the len(fileContent) call is returning 0. Any
> suggestions?
Perhaps GzipFile reads from the current position till end (and sees
nothing).
Try rewinding the file:
> decodedVersion = StringIO.StringIO()
> base64.decode(open(infile, 'r'),decodedVersion)
decodedVersion.seek(0)
> fileObj = gzip.GzipFile(fileobj=decodedVersion);
> fileContent = fileObj.read()
> print len(fileContent)
--
Gabriel Genellina
More information about the Python-list
mailing list