import pandas as pd
import json
import io
pd.set_option('mode.chained_assignment',None)
def get_scryfall_id(row):
return row["identifiers"]["scryfallId"]
# Art link options: "small", "normal", "large", "png", "art_crop", border_crop
def get_art_link(row):
return row["image_uris"]["art_crop"]
with open("C:\\Users\\chris\\Desktop\\LEA.json", "r", encoding="utf8") as file:
lea = json.load(file)
with open("C:\\Users\\chris\\Desktop\\artwork.json", "r", encoding="utf8") as file:
art = json.load(file)
lea_df = pd.DataFrame.from_dict(lea["data"]["cards"])
art_df = pd.DataFrame.from_dict(art)
alpha_df_lea = lea_df[(lea_df.setCode == "LEA")]
alpha_df_art = art_df[(art_df.set == "lea")]
alpha_df_lea["scryfallid"] = alpha_df_lea.apply(lambda row: get_scryfall_id(row), axis=1)
alpha_df_art["artlink"] = alpha_df_art.apply(lambda row: get_art_link(row), axis=1)
merged_df = pd.merge(left=alpha_df_lea, right=alpha_df_art, how="inner", left_on="scryfallid", right_on="id")
merged_df.to_csv("C:\\Users\\chris\\Desktop\\lea_card_data.csv", index=False)