Created
April 19, 2016 17:37
-
-
Save nmilford/2c87d080504a06477b89f04c257d8b14 to your computer and use it in GitHub Desktop.
Uncompress and Unpickle a compressed PickledObjectField
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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