Compare commits

...

1 commit
v1.0 ... main

Author SHA1 Message Date
Dan Niemitalo
e17e9a349c 2024 Fixes
1) The CubeCobra CSV headers have changed slightly, capitalizing some words.
2) Cards in the maybeboard should not be included in the averages, so this filters them out.
3) Minor simplifications made to the keyword and word count analysis files to make it a bit easier for amateurs like me to figure out how to run these scripts.
2024-06-09 10:18:30 -05:00
3 changed files with 23 additions and 13 deletions

View file

@ -6,8 +6,10 @@ import cubecobra_csv
import keyword_stats import keyword_stats
if __name__ == '__main__': if __name__ == '__main__':
cube_list = cubecobra_csv.load_cube_names('cube_csvs/TheElegantCube_2020-11-17_5.0.4.csv', {'core'}) cube_id = 'jeskaicube'
cube_json_filename = cube_json.create_cube_json(cube_list, 'cubes/TheElegantCube_2020-11-17_5.0.4.json') csv_path = cubecobra_csv.request_cube_csv(cube_id, cube_id)
cube_list = cubecobra_csv.load_cube_names(f'cube_csvs/{cube_id}.csv')
cube_json_filename = cube_json.create_cube_json(cube_list, f'cubes/{cube_id}.json')
keyword_dict = keyword_stats.keyword_count(cube_json_filename) keyword_dict = keyword_stats.keyword_count(cube_json_filename)
# keyword_stats.keyword_report(keyword_dict) # keyword_stats.keyword_report(keyword_dict)

View file

@ -7,7 +7,7 @@ from typing import List, Set
import requests import requests
EXPECTED_HEADER = [ EXPECTED_HEADER = [
'Name', 'name',
'CMC', 'CMC',
'Type', 'Type',
'Color', 'Color',
@ -15,12 +15,12 @@ EXPECTED_HEADER = [
'Collector Number', 'Collector Number',
'Rarity', 'Rarity',
'Color Category', 'Color Category',
'Status', 'status',
'Finish', 'Finish',
'Maybeboard', 'maybeboard',
'Image URL', 'image URL',
'Image Back URL', 'image Back URL',
'Tags', 'tags',
'Notes', 'Notes',
'MTGO ID' 'MTGO ID'
] ]
@ -95,7 +95,8 @@ def load_cube(filename) -> List[CubeCard]:
tags = _get_tags(line) tags = _get_tags(line)
color_category = _get_color_category(line) color_category = _get_color_category(line)
colors = _get_colors(line) colors = _get_colors(line)
cards.append(CubeCard(card_name, color_category, colors, tags)) if not _get_maybeboard(line):
cards.append(CubeCard(card_name, color_category, colors, tags))
return cards return cards
@ -104,11 +105,11 @@ def _assert_header(header_line):
def _get_name(line: List) -> str: def _get_name(line: List) -> str:
return line[COLUMNS['Name']] return line[COLUMNS['name']]
def _get_tags(line: List) -> Set[str]: def _get_tags(line: List) -> Set[str]:
return set(t.strip() for t in line[COLUMNS['Tags']].split(';')) return set(t.strip() for t in line[COLUMNS['tags']].split(';'))
def _get_color_category(line: List) -> str: def _get_color_category(line: List) -> str:
@ -121,3 +122,9 @@ def _get_colors(line: List) -> str:
colors = line[COLUMNS['Color']] colors = line[COLUMNS['Color']]
#assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown' #assert color_category in _COLOR_CATEGORIES, f'color_category "{color_category}" unknown'
return sorted(colors.lower()) return sorted(colors.lower())
def _get_maybeboard(line: List) -> str:
maybeboard = line[COLUMNS['maybeboard']]
if 't' in maybeboard.lower():
return True
return False

View file

@ -173,8 +173,9 @@ if __name__ == '__main__':
# cube_list = cubecobra_csv.load_cube_names(csv_path) # cube_list = cubecobra_csv.load_cube_names(csv_path)
# 2. If you have your cube in Cube Cobra and want to consider only cards with a certain tag # 2. If you have your cube in Cube Cobra and want to consider only cards with a certain tag
csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant') cube_id = 'jeskaicube'
cube_list = cubecobra_csv.load_cube_names(csv_path, tag_filter={'core'}) csv_path = cubecobra_csv.request_cube_csv(cube_id, cube_id)
cube_list = cubecobra_csv.load_cube_names(csv_path, tag_filter=None)
# 3. If you have a .txt of your cube # 3. If you have a .txt of your cube
# cube_list = cube_json.load_cube_from_txt('YourCubeHere.txt') # cube_list = cube_json.load_cube_from_txt('YourCubeHere.txt')