diff --git a/data/third_party_json/spells.py b/data/third_party_json/spells.py new file mode 100644 index 0000000..aad7eda --- /dev/null +++ b/data/third_party_json/spells.py @@ -0,0 +1,37 @@ +import json + +def main(): + # load json into python + print("loading json") + ## read file into memory + with open('spells.json') as f: + # raw_data = f.read() + data = json.load(f) + print("Imported {} spells.".format(len(data))) + # alphabetize spells into a list + sorted_names = [] + for i in data: + sorted_names.append(i['name']) + sorted_names.sort() + # print(sorted_names) + + # get list of dicts in order + sorted_dicts = [] # sorted by ['name'] alphabetically + for i in sorted_names: + for x in data: + # yes, I know this is double nested and not that efficient; don't + # care yet, it's not that many items + if x['name'] == i: + sorted_dicts.append(x) + + # NOW we can go alphabetically spell by spell + for i in sorted_dicts: + do_sql(i) + +# TODO write this function after sql schema drafted +def do_sql(): + pass + + +if __name__ == "__main__": + main()