correction changes

This commit is contained in:
Zach H 2016-07-16 23:42:30 -04:00
parent 27954b1faa
commit 50b032484f
3 changed files with 14 additions and 890673 deletions

890665
Output.json

File diff suppressed because it is too large Load diff

View file

@ -38,7 +38,6 @@ def json_to_db(json_file_opened, database_connection):
setName = data["name"]
setReleaseDate = data["releaseDate"]
setCards = data["cards"] # Now iterate through the setCards for each card in the set
for thisCard in setCards:
@ -88,14 +87,14 @@ def json_to_db(json_file_opened, database_connection):
c.close()
def main():
i = sys.argv[1] #input("Create new database? 1 or 0: ")
d = os.path.join(os.path.expanduser(sys.argv[2]), "Magic DB.db"); #input("Location of database: ")
i = sys.argv[1] # Should create new DB
d = os.path.expanduser(sys.argv[2]) # File location for database
d = sqlite3.connect(d)
if (i == '1'):
create_db(d)
xml = os.path.join(os.path.expanduser(sys.argv[3]), "AllSets-x.json") #input("Location of AllSets-x.json: ")
xml = os.path.expanduser(sys.argv[3]) # File location for input file
xml = json.load(open(xml, 'r'))
json_to_db(xml, d)

View file

@ -27,22 +27,29 @@ def db_to_json(database_connection):
cursor.execute("SELECT * FROM cards WHERE setCode = '%s'" % setCode["setCode"])
card_rows = cursor.fetchall()
setName = None
setReleaseDate = None
for row in card_rows:
row = remove_empty_keys(dict_from_row(row))
returnData.append(row)
if not setName and not setReleaseDate:
setName = row["setName"]
setReleaseDate = row["setReleaseDate"]
mainDict[setCode["setCode"]] = returnData
mainDict[setCode["setCode"]] = dict(zip(["cards", "name", "releaseDate"], [returnData, setName, setReleaseDate]))
setName = None
setReleaseDate = None
returnData = []
database_connection.close()
return mainDict
def main():
d = os.path.join(os.path.expanduser(sys.argv[1]), "Magic DB.db")
d = os.path.expanduser(sys.argv[1]) # File location for database
d = sqlite3.connect(d)
xml = os.path.join(os.path.expanduser(sys.argv[2]), "Output.tmp.json")
xml2 = os.path.join(os.path.expanduser(sys.argv[2]), "Output.json")
xml = "/tmp/Output.tmp.json"
xml2 = os.path.expanduser(sys.argv[2]) # File location for output
json_code = json.dumps(db_to_json(d), sort_keys=True, indent=2)