Permalink
Browse files

Get list of all MtG Instants/Sorceries

  • Loading branch information...
minimaxir committed Sep 25, 2017
1 parent 6f89868 commit 3f626ae5d49a567322c6237210ab554281d462f4
Showing with 22 additions and 0 deletions.
  1. +22 −0 get_cardlist.py
View
@@ -0,0 +1,22 @@
import json
import csv
file_path = "/Users/maxwoolf/Downloads/AllSets.json"
with open('cards.csv', 'w', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['id', 'name'])
with open(file_path, 'r') as data:
all_sets = json.load(data)
sets = all_sets.keys()
for set in sets:
cards = all_sets[set]['cards']
for card in cards:
if 'multiverseid' in card:
type = card.get('type')
if (type is not None and
type == "Instant" or
type == "Sorcery" and
card['layout'] == 'normal'):
writer.writerow([card['name'], card['multiverseid']])

0 comments on commit 3f626ae

Please sign in to comment.