eafd74f1 by Barry

Initial commit with the output from one run.

0 parents
import untangle
import sys
import os
import argparse
import sqlite3
import shlex
# To Install:
# * Install python 2.7.X
# * pip install untangle
# Edit the fields below for each file. If there are other files just add them to the hash.
field_list = {
"items-armor.xml":
["id", "flags", "name", "description", "level", "iLevel", "slots", "races"],
"items-armor2.xml":
["id", "flags", "name", "description", "level", "iLevel", "slots", "races"],
"items-currency.xml":
["id", "flags", "name", "description", "log-name-singular", "log-name-plural"],
"items-general.xml":
["id", "flags", "name", "description"],
"items-general2.xml":
["id", "flags", "name", "description"],
"items-puppet.xml":
["id", "flags", "name", "description", "puppet-slot", "element-charge"],
"items-usable.xml":
["id", "flags", "name", "description", "activation-time"],
"items-voucher-slip.xml":
["id", "flags", "name", "description", "valid-targets"],
"items-weapons.xml":
["id", "flags", "name", "description", "level", "iLevel", "slots", "races", "damage"],
}
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--sourcexml', required=True, help="Source XML Directory")
parser.add_argument('-o', '--outputdb', required=True, help="Destination SQLite Database")
args = parser.parse_args()
print "Source XML Directory: %s" % (args.sourcexml,)
print "Destination SQLite DB: %s" % (args.outputdb,)
conn = sqlite3.connect(args.outputdb)
c = conn.cursor()
for filename in os.listdir(args.sourcexml):
if filename.endswith(".xml"):
try:
fields = (', '.join('"' + item + '"' for item in field_list[filename]))
query = "CREATE TABLE \"%s\" (%s)" % (filename, fields)
print query
c.execute(query)
conn.commit()
except sqlite3.OperationalError:
pass
source_file = os.path.join(args.sourcexml, filename)
print "Parsing File: %s" % (source_file,)
doc = untangle.parse(source_file)
for item in doc.thing_list.thing:
row = []
for field in item.children:
if field['name'] in field_list[filename]:
row.append(field.cdata)
query = "INSERT INTO \"%s\" VALUES(%s)" % (filename, ','.join('?' * len(row)))
c.execute(query, row)
conn.commit()
c.close()
\ No newline at end of file
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<?xml version="1.0" encoding="utf-8"?>
<thing-list>
<thing type="Item">
<field name="id">65535</field>
<field name="flags">0000</field>
<field name="stack-size">57599</field>
<field name="type">0009</field>
<field name="resource-id">0</field>
<field name="valid-targets">0000</field>
<field name="name">Gil</field>
<field name="description">The currency of Vana'diel.</field>
<field name="log-name-singular">Gil</field>
<field name="log-name-plural">Gils</field>
<field name="icon">
<thing type="Graphic">
<field name="format">8-bit Bitmap</field>
<field name="flag">145</field>
<field name="category">coin</field>
<field name="id">coin</field>
<field name="width">32</field>
<field name="height">32</field>
<field name="planes">1</field>
<field name="bits">8</field>
<field name="compression">0</field>
<field name="size">0</field>
<field name="horizontal-resolution">0</field>
<field name="vertical-resolution">0</field>
<field name="used-colors">0</field>
<field name="important-colors">32</field>
<field name="image" format="image/png" encoding="base64">iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAb1SURBVFhHzZZ9TJV1FMf9i7WcL5vmFpEiA+Tl8iJcUpLNSKzEgcjCjDCVt5E44IowEUGQ1xAIVEAQuhIiIqKoaRIyJ2EqpZgrUzeXazW35mqrVW5tnp7P4V6WRk2cbf22357nPi/nfM/3fM/3uRP+t2vatGkO06dPd2Yb5ybjGPIPm/sOtteezCIgSWOXzszOWxcsrWVm+bjJR74+6iu/nAvS85aiAOEez/DsEwNhVDRjedjziST99WKwfNc7X9oKfWRHlkmKU9iukvq6s7TkecuJHb5yqt5PSi1m4R3etYV5vAWdljiXyt9/jhS5v0KT1GR6SU6ci+wrMsnerV5Smj5T3k1zlcL1TrI93VPqN7kpkIPVgZK0cqFMmTLF2RZufAv0JL97MVTkmyWSG+8uvTv9pWGDpwz3vChfHF8gZ/bOlV5rgJzcPVevA2JXtqvsyJijTAxaR0CMmwn6B4WffDBPbn4YIqcbAjRgd7Gv/PT5IjnfGSQnm8zSYwAiCb/P7DFJX0WQgugo9dA2nW8LkP6mQG3HI2vC0dHxaURUus5dA+escdXKD5fPld8GFoncWar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tvec4H8JCVCRD4QDkCIBbvT4KDvsGNMmpvr9tnuRvzpDCwkLp6OjQFmBCvb29CgINcO8BAKypU6fOiA13LEfpfNsJTnWAwOlIDLi9pSNjyrHH0Aj3ECui45O9PjFKZx6qSc5KSkpSyq9fv67J6+rqVAcGgDBb+pGFTQKCsYJq/vkQnOpIRGuonr5vjHdSLfAMHyNAJ8a9Nmo+9B0Q9+7dk6GhIa2YIy3AjEZF+PCCiYXmGfHvxBr/coxxI3jtZnf1hBWLR3by8lmamOu0Df0w46ieeafH2C/JaENWVpZeN2xYdYEY+U7oGI61Jk+e/BRO9VLQM9kAKbO4SXOxp7LC5jw/1SSpq1+QN2OWavLo6GitnplHdFSJ45WUlMilS5cUDOd4AeyEhobWoD1byrEXQCZNmuRu7BBjXSUJOzw8nAC6+c24rV27VvtLYs758KABktpVzyjevn1bnxu14kdZAPH390+kUqq0A4BykhEYZ+MelfIbyu3XoB71Y8F8C4KDgwv4J2YL/2hr4sSJjtDGfEMzQakeUKiepPSaI0lQOn3GjnkORq5cuSLLli2rJ5Yt7PgWUwIIKMTNGC+SUy1MIDAY4DqVc49zWgAAkhPDFu7xFujNZvN6gqNwTIaqGT17QiYAzyex1WpVjfDOY1f+8KJ/iIheUj2qx3JRN27H/NtHj2d4dtw9f5RFUKqyT8oY2/0/Sfzk1oQJfwIfwgcqxp13OQAAAABJRU5ErkJggg==</field>
</thing>
</field>
<field name="unknown-2">0</field>
</thing>
</thing-list>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.