Skip to content

Instantly share code, notes, and snippets.

@nmilford
Created April 19, 2016 17:37
Show Gist options
  • Save nmilford/2c87d080504a06477b89f04c257d8b14 to your computer and use it in GitHub Desktop.
Save nmilford/2c87d080504a06477b89f04c257d8b14 to your computer and use it in GitHub Desktop.
Uncompress and Unpickle a compressed PickledObjectField
import pickle
from base64 import b64decode
from zlib import decompress
import xml.dom.minidom
def parse_pickled_transcript(value):
value = value.encode()
value = b64decode(value)
value = decompress(value)
result = pickle.loads(value)
xml = xml.dom.minidom.parseString(result)
xml_string = xml.toprettyxml()
xml_file = open("output.xml", "w")
xml_file.write(xml_string)
xml_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment