gaddlord / mtg.studio

Issue tracker and wiki for MTG Studio - Magic: the Gathering deck editor and collection builder
https://mtg.studio
5 stars 0 forks source link

Support importing from TCG Player mobile app #86

Open gaddlord opened 2 years ago

gaddlord commented 2 years ago

Using the TCGPlayer iOS app allows for quicker cataloging of cards then manually entering them in, plus allows for csv export. However I need to modify the csv from TCGPlayer quite a bit to fit the MTG Studio csv format. For example, removing and ordering columns, and modifying set codes. From TCGPlayer "5ED" to MTGStudio "5E". Adventure and dual face cards are also problematic.

Votes: 2 by 2 suporters id: 43522584 Created: 28.05.2021 10:56 by (gerad_n [at] hotmail.com) Updated: 02.01.2022 03:40

gaddlord commented 2 years ago

William Boudle: Some other comments on this as I have to do it often. It only uses the front side name on dual sided cards. it uses () instead of [] Foil/Normal vs y/n.

Even if one of the other card scanners easily integrated or you made your own ( probably much harder). That would be great.

sc4rr3d commented 10 months ago

@gaddlord thankyou for moving this request over from the old forum, I hope this is helpful to others that may also be using the same process to catalog cards.

I've been using this basic jupyter notebook with python to edit the default output from the TCGplayer iOS app to better fit the MTG.studio CSV import process. I've attached the notebook, with comments, a TCG export sample file from recent collection and the .csv output of this python code.

The script gets 95%+ of the cards in the correct format noting there is still an issue with adventure / double-sided cards and some alternate art or showcase cards that need to be added manually for now.

#!/usr/bin/env python
# coding: utf-8
import pandas as pd
df = pd.read_csv("TCGplayerCardList (13).csv")
# Remove columns (Simple Name, Set, Card Number, External ID, Language, Rarity, Product ID, SKU, Price, Price Each)
df.drop(["Simple Name", "Set", "Card Number", "External ID", "Language", "Rarity", "Product ID", "SKU", "Price", "Price Each"], axis=1, inplace=True)

# Rename column Quantity = Qty
df = df.rename(columns={"Quantity":"Qty"})

# Rename column Set Code = Set
df = df.rename(columns={"Set Code":"Set"})

# Rename column Printing = Foil
df = df.rename(columns={"Printing":"Foil"})

# Add two columns with blank data (Price, Notes)
df["Price"] = ""
df["Notes"] = ""

# Reorder the columns without losing data to (Name, Set, Qty, Foil, Price, Condition, Notes)
df = df[["Name","Set","Qty","Foil","Price","Condition","Notes"]]

# Within the Foil column, replace "Normal" with "n" and "Foil" with "y"
def change_foil(df):

    if df["Foil"] == "Foil":
        return "y"
    elif df["Foil"] == "Normal":
        return "n"
    else:
        pass

df["Foil"] = df.apply(change_foil, axis=1)

# change Set from column 1 to column 2
df_sets = pd.read_csv("MTGSets.csv")
df_sets.index= df_sets["old"]
df_sets.drop("old", axis=1, inplace=True)#.to_dict(orient="series")
dict_sets = df_sets.to_dict(orient="dict")["new"]

def update_set(df):
    if df["Set"] in dict_sets.keys():
        return dict_sets[df["Set"]]
    else:
        return df["Set"]

df["Set"] = df.apply(update_set, axis=1)

# change () to []
df["Name"] = df["Name"].str.replace("(", "[").str.replace(")", "]")

# Export to CSV
df.to_csv("TCGplayerCardList_20240106.csv", index=False)