import itertools from flashcards.config import config from flashcards.maps import (create_maps, read_data_to_dict, read_name_data_to_dict) # --- General section to read in names and data # specify the namelist to be used to create the deck # give the relative path of the file from config.namelists_dir namelist = 'research-standard.txt' # key into json file specifying which data you want name_json_keys = 'techs' data_json_keys = ('civs',) _, nums = create_maps(namelist, name_json_keys) data = read_data_to_dict(data_json_keys) non_uniques = [] uniques = [] for name, num in nums.items(): count = 0 recent_civ = None for civ in data.keys(): if int(num) in data[civ]['Tech']: count += 1 recent_civ = civ if count == 1: #print(f'{name}: {recent_civ}') uniques.append(name) elif count > 1: non_uniques.append(name) with open(config.namelists_dir / 'research-unique.txt', 'w') as f: f.writelines('\n'.join(uniques)) f.write('\n') with open(config.namelists_dir / 'research-non-unique.txt', 'w') as f: f.writelines('\n'.join(non_uniques)) f.write('\n')