http://www.mapeditor.org/wiki/Examining_the_map_format
To start I tried:
code = base64.b64decode("H4sIAAAAAAAAAO3NoREAMAgEsLedAfafE4+s6l0jolNJiif18tt/Fj8AAMC9ARtYg28AEAAA")
code = zlib.decompress(code)
But I get:
zlib.error: Error -3 while decompressing data: incorrect header check
How can I solve this?
Thanks,
Niels.
> zlib.error: Error -3 while decompressing data: incorrect header check
>
> How can I solve this?
The link you quoted says "you need to first base64 decode
the string, then gunzip the resulting data" ... so gunzip it:
| >>> s0 =
"H4sIAAAAA......"
| >>> import base64
| >>> s1 = base64.b64decode(s0)
| >>> len(s0)
| 72
| >>> len(s1)
| 54
| >>> import StringIO
# or cStringIO or io depending on what
# Python versions you want to support
| >>> sio = StringIO.StringIO(s1)
| >>> import gzip
| >>> gzf = gzip.GzipFile(fileobj=sio)
| >>> guff = gzf.read()
| >>> len(guff)
| 4096
| >>> guff[:100]
| '\x1b\x00\x00\x00\x1b\x00\x00\x00\x1b\x00\x00\x00 [snip]
What a long journey: parse xml, base64 decode, gunzip,
and you're still not home; next stop is struct.unpack ...
HTH,
John
Thanks for the help! I dont think I could have done that.
And thanks for the tip on struct.unpack I managed to get a list of
integers to work with.
Niels
You might make do with array.fromstring (perhaps using .byteswap
afterwards) to get your numbers if you are talking more than a handful.
--Scott David Daniels
Scott....@Acm.Org
> What a long journey: parse xml, base64 decode, gunzip,
> and you're still not home; next stop is struct.unpack ...
Binary data in an XML file?? Were these the same folks who worked on OOXML,
by any chance?