Skip to content

Instantly share code, notes, and snippets.

@hunterowens
Created November 29, 2014 18:57
Show Gist options
  • Save hunterowens/92d9286461979fd400f6 to your computer and use it in GitHub Desktop.
Save hunterowens/92d9286461979fd400f6 to your computer and use it in GitHub Desktop.
XML->CSV
import xmltodict
import json
import pandas as pd
file = open('/path/to/file.xml','r')
str = file.read()
dictionary = xmltodict.parse(str)
df = pd.DataFrame(dictionary)
# Do any parsing of the XML file here, as you'll want to confirm that you are writing the correct info to csv.
df.to_csv('/path/to/output.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment