From 283f1abbdd41703e5358ed5d9727af699715429d Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Wed, 21 Feb 2018 14:53:35 -0500 Subject: [PATCH] Created check_collection.py --- examples/check_collection.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/check_collection.py diff --git a/examples/check_collection.py b/examples/check_collection.py new file mode 100644 index 0000000..0b6629d --- /dev/null +++ b/examples/check_collection.py @@ -0,0 +1,35 @@ +""" +This script assumes the following: +1. All of the names in your collection .csv are on the first column +2. All of those names are spelled correctly. +3. The .csv only contains cards that you have in your collection. +""" +import csv +import scrython +import time + +# You can replace fileName here with your .csv file path if you only have one file. +fileName = input("Please enter the name of the file you'd like to scan: ") +searchQuery = input("Enter your Scryfall query: ") + +search = scrython.cards.Search(q=searchQuery, page=1) + +total = search.total_cards() + +totalNames = [] + +for i in range(len(search.data())): + totalNames.append(search.data()[i]['name']) + +if total > len(search.data()): + time.sleep(0.05) + search2 = scrython.cards.Search(q=searchQuery, page=2) + for i in range(len(search2.data())): + totalNames.append(search.data()[i]['name']) + +with open(fileName, 'r') as f: + reader = csv.reader(f, delimiter=",") + print("\nYou own of at least 1 copy of the following:\n") + for value in reader: + if value[0] in totalNames: + print(value[0])