![](/static/253f0d9b/assets/icons/icon-96x96.png)
![](https://mtgzone.com/pictrs/image/05b4ac61-364e-4713-9e2e-683933bef82a.webp)
Here are step-by-step instructions to migrate decks_v2.json
to .dck
files with the desired structure, assuming no prior knowledge of the command line:
migrate_decks.py
.import json
def migrate_decks_v2():
with open('decks_v2.json', 'r') as f:
decks = json.load(f)
for deck in decks:
filename = deck['name'].lower()replace(' ', '_') + '.dck'
with open(filename, 'w') as f:
f.write(f"// {deck['name']}\n")
f.write(f"// Set: {deck['set_name']} ({deck['set_code']})\n")
f.write(f"// Release Date: {deck['release_date']}\n")
f.write('\n')
for card in deck['cards']:
f.write(f"{card['count']} [{card['set_code']}:{card['number']}] {card['name']}\n")
f.write('\n')
f.write('SB:\n')
for card in deck['sideboard']:
f.write(f"{card['count']} [{card['set_code']}:{card['number']}] {card['name']}\n")
migrate_decks_v2()
decks_v2.json
file and the migrate_decks.py
file are located. You can do this by typing cd
followed by the path to the folder, such as cd C:\Users\YourName\Downloads\magic-preconstructed-decks-master
.python migrate_decks.py
and press Enter to run the Python script..dck
file for each deck in the decks_v2.json
file, with the desired structure.Note: If you don’t have Python installed on your computer, you can download it from the official website: https://www.python.org/downloads/. Choose the latest version for your operating system and follow the installation instructions.
TODO: need to check what to do with the commander in EDH decklists
https://github.com/taw/magic-preconstructed-decks-data/blob/master/README.md
This repository contains machine readable decklist data generated from:
Files
decks.json
has traditional cards + sideboard structure, with commanders reusing sideboard.
decks_v2.json
has cards + sideboard + commander structure. You should use this one.Data format
Data file i a JSON array, with every element representing one deck.
Fields for each deck:
- name - deck name
- type - deck type
- set_code - mtgjson set code
- set_name - set name
- release_date - deck release date (many decks are released much after their set)
- cards - list of cards in the deck’s mainboard
- sideboard - list of cards in the deck’s sideboard
- commander - any commanders deck has (can be multiple for partners)
Each card is:
- name - card name
- set_code - mtgjson set card is from (decks often have cards from multiple sets)
- number - card collector number
- foil - is this a foil version
- count - how many of given card
- mtgjson_uuid - mtgjson uuid
- multiverseid - Gatherer multiverseid of card if cards is on Gatherer (optional field)
Data Limitations
All precons ever released by Wizards of the Coast should be present, and decklists should always contain right cards, with correct number and foiling, and mainboard/sideboard/commander status.
Source decklists generally do not say which printing (set and card number) each card is from, so we need to use heuristics to figure that out.
We use a script to infer most likely set for each card based on some heuristics, and as far as I know, it always matches perfectly.
That just leaves situation where there are multiple printings of same card in same set.
If some of the printings are special (full art basics, Jumpstart basics, showcase frames etc.), these have been manually chosen to match every product.
If you see any errors for anything mentioned above, please report them, so they can be fixed.
That just leaves the case of multiple non-special printings of same card in same set - most commonly basic lands. In such case one of them is chosen arbitrarily, even though in reality a core set deck with 16 Forests would likely have 4 of each Forest in that core set, not 16 of one of them.
Feel free to create issue with data on exact priting if you want, but realistically we’ll never get them all, and it’s not something most people care about much.
tappedout exports as csv with set information:
.csv
Board,Qty,Name,Printing,Foil,Alter,Signed,Condition,Language
main,1,Beacon Bolt,GRN,,,,,
.dck
1 [GRN:?] Beacon Bolt
Here is a Python script that reads the .csv file and writes the required format to a .dck file. This script uses the csv module to read the .csv file and write to the .dck file.
import csv
def read_csv_file(file_path):
with open(file_path, 'r') as file:
return list(csv.reader(file))
def write_to_dck_file(file_path, data):
with open(file_path, 'w') as file:
file.writelines(data)
def convert_csv_to_dck_format(csv_data):
csv_header, *csv_rows = csv_data
return [format_dck_line(row) for row in csv_rows]
def format_dck_line(row):
quantity, name, printing = row[1], row[2], row[3]
return f"{quantity} [{printing}:?] {name}\n"
csv_data = read_csv_file('input.csv')
dck_data = convert_csv_to_dck_format(csv_data)
write_to_dck_file('output.dck', dck_data)
This script works as follows:
next()
function.Please replace ‘input.csv’ with the path to your .csv file and ‘output.dck’ with the path where you want to create the .dck file. Run this script in a Python environment, and it will create the .dck file with the required format.
More violent and frequent rotations: