eafd74f1 by Barry

Initial commit with the output from one run.

0 parents
1 import untangle
2 import sys
3 import os
4 import argparse
5 import sqlite3
6 import shlex
7
8 # To Install:
9 # * Install python 2.7.X
10 # * pip install untangle
11
12 # Edit the fields below for each file. If there are other files just add them to the hash.
13
14 field_list = {
15 "items-armor.xml":
16 ["id", "flags", "name", "description", "level", "iLevel", "slots", "races"],
17 "items-armor2.xml":
18 ["id", "flags", "name", "description", "level", "iLevel", "slots", "races"],
19 "items-currency.xml":
20 ["id", "flags", "name", "description", "log-name-singular", "log-name-plural"],
21 "items-general.xml":
22 ["id", "flags", "name", "description"],
23 "items-general2.xml":
24 ["id", "flags", "name", "description"],
25 "items-puppet.xml":
26 ["id", "flags", "name", "description", "puppet-slot", "element-charge"],
27 "items-usable.xml":
28 ["id", "flags", "name", "description", "activation-time"],
29 "items-voucher-slip.xml":
30 ["id", "flags", "name", "description", "valid-targets"],
31 "items-weapons.xml":
32 ["id", "flags", "name", "description", "level", "iLevel", "slots", "races", "damage"],
33
34 }
35
36 parser = argparse.ArgumentParser()
37 parser.add_argument('-s', '--sourcexml', required=True, help="Source XML Directory")
38 parser.add_argument('-o', '--outputdb', required=True, help="Destination SQLite Database")
39 args = parser.parse_args()
40
41 print "Source XML Directory: %s" % (args.sourcexml,)
42 print "Destination SQLite DB: %s" % (args.outputdb,)
43
44 conn = sqlite3.connect(args.outputdb)
45 c = conn.cursor()
46
47 for filename in os.listdir(args.sourcexml):
48 if filename.endswith(".xml"):
49 try:
50 fields = (', '.join('"' + item + '"' for item in field_list[filename]))
51 query = "CREATE TABLE \"%s\" (%s)" % (filename, fields)
52 print query
53 c.execute(query)
54 conn.commit()
55 except sqlite3.OperationalError:
56 pass
57 source_file = os.path.join(args.sourcexml, filename)
58 print "Parsing File: %s" % (source_file,)
59 doc = untangle.parse(source_file)
60 for item in doc.thing_list.thing:
61 row = []
62 for field in item.children:
63 if field['name'] in field_list[filename]:
64 row.append(field.cdata)
65
66 query = "INSERT INTO \"%s\" VALUES(%s)" % (filename, ','.join('?' * len(row)))
67 c.execute(query, row)
68 conn.commit()
69
70 c.close()
...\ No newline at end of file ...\ 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.
1 <?xml version="1.0" encoding="utf-8"?>
2 <thing-list>
3 <thing type="Item">
4 <field name="id">65535</field>
5 <field name="flags">0000</field>
6 <field name="stack-size">57599</field>
7 <field name="type">0009</field>
8 <field name="resource-id">0</field>
9 <field name="valid-targets">0000</field>
10 <field name="name">Gil</field>
11 <field name="description">The currency of Vana'diel.</field>
12 <field name="log-name-singular">Gil</field>
13 <field name="log-name-plural">Gils</field>
14 <field name="icon">
15 <thing type="Graphic">
16 <field name="format">8-bit Bitmap</field>
17 <field name="flag">145</field>
18 <field name="category">coin</field>
19 <field name="id">coin</field>
20 <field name="width">32</field>
21 <field name="height">32</field>
22 <field name="planes">1</field>
23 <field name="bits">8</field>
24 <field name="compression">0</field>
25 <field name="size">0</field>
26 <field name="horizontal-resolution">0</field>
27 <field name="vertical-resolution">0</field>
28 <field name="used-colors">0</field>
29 <field name="important-colors">32</field>
30 <field name="image" format="image/png" encoding="base64">iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAb1SURBVFhHzZZ9TJV1FMf9i7WcL5vmFpEiA+Tl8iJcUpLNSKzEgcjCjDCVt5E44IowEUGQ1xAIVEAQuhIiIqKoaRIyJ2EqpZgrUzeXazW35mqrVW5tnp7P4V6WRk2cbf22357nPi/nfM/3fM/3uRP+t2vatGkO06dPd2Yb5ybjGPIPm/sOtteezCIgSWOXzszOWxcsrWVm+bjJR74+6iu/nAvS85aiAOEez/DsEwNhVDRjedjziST99WKwfNc7X9oKfWRHlkmKU9iukvq6s7TkecuJHb5yqt5PSi1m4R3etYV5vAWdljiXyt9/jhS5v0KT1GR6SU6ci+wrMsnerV5Smj5T3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iWITrYuH9rkQJHA1Sfb3lFGaBiNFBWVqbb3pLqqmoAhOgHKDrsuWxeolJsFTPB4TAn6Oe7gKpxO4wHENyH8pL1s6V2g7PuukxnZRFLx4hSUlIkPz9fx5DkVA4YvKG9vR23DIMB/fZnJQVqQiog2OUDwep20M5nGIppA+PGzAMKlmADIFsSnfQI0F0Fi3T88vLypLa2VkG0trZq1bSioqJCuru7ARBlF6LDqyHPxlOtvec4H8JCVCRD4QDkCIBbvT4KDvsGNMmpvr9tnuRvzpDCwkLp6OjQFmBCvb29CgINcO8BAKypU6fOiA13LEfpfNsJTnWAwOlIDLi9pSNjyrHH0Aj3ECui45O9PjFKZx6qSc5KSkpSyq9fv67J6+rqVAcGgDBb+pGFTQKCsYJq/vkQnOpIRGuonr5vjHdSLfAMHyNAJ8a9Nmo+9B0Q9+7dk6GhIa2YIy3AjEZF+PCCiYXmGfHvxBr/coxxI3jtZnf1hBWLR3by8lmamOu0Df0w46ieeafH2C/JaENWVpZeN2xYdYEY+U7oGI61Jk+e/BRO9VLQM9kAKbO4SXOxp7LC5jw/1SSpq1+QN2OWavLo6GitnplHdFSJ45WUlMilS5cUDOd4AeyEhobWoD1byrEXQCZNmuRu7BBjXSUJOzw8nAC6+c24rV27VvtLYs758KABktpVzyjevn1bnxu14kdZAPH390+kUqq0A4BykhEYZ+MelfIbyu3XoB71Y8F8C4KDgwv4J2YL/2hr4sSJjtDGfEMzQakeUKiepPSaI0lQOn3GjnkORq5cuSLLli2rJ5Yt7PgWUwIIKMTNGC+SUy1MIDAY4DqVc49zWgAAkhPDFu7xFujNZvN6gqNwTIaqGT17QiYAzyex1WpVjfDOY1f+8KJ/iIheUj2qx3JRN27H/NtHj2d4dtw9f5RFUKqyT8oY2/0/Sfzk1oQJfwIfwgcqxp13OQAAAABJRU5ErkJggg==</field>
31 </thing>
32 </field>
33 <field name="unknown-2">0</field>
34 </thing>
35 </thing-list>
...\ No newline at end of file ...\ 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.