import json print("HI") with open('./openTimes.json') as f: x = json.loads(f.read()) """Yes, this file is totally unnecessary but I didn't have access to the dumpdata command so I did this.""" newList = list() open_times = list() for i in x: nextSet = { "pk": None, "model": "api.OpenTime", "fields": i } #{ "model":"api.category", "pk": i[1]["id"], "fields":{ "name": i[1]["name"] } } newList.append(nextSet) """ #For schedules cpy = dict(i) open_times += list( i["open_times"] ) del( cpy["id"] ) del( cpy["open_times"] ) nextSet = { "pk": i["id"], "model": "api.schedule", "fields": cpy } #{ "model":"api.category", "pk": i[1]["id"], "fields":{ "name": i[1]["name"] } } newList.append(nextSet) """ """ #for categories nextSet = { "model":"api.category", "pk": i[1]["id"], "fields":{ "name": i[1]["name"] } } #for buildings """ """ #FOR LOCATION coords = i["coordinate_location"]["coordinates"] nextSet = { "fields": { "building": i["building"], "friendly_building": i["friendly_building"], "address": i["address"], "campus_region": i["campus_region"], "coordinate_location":"SRID=4326;POINT (" + str(coords[0]) + " " + str(coords[1]) + ")" ,"on_campus":i["on_campus"], }, "model": "api.location", "pk": i["id"] } """ with open("./fixtureOut.json", "w") as f: json.dump(newList, f)