def find_match_ids_datdota(self): with open(self.query_file) as f: def remove_bom(line): return line.lstrip("") reader = csv.DictReader((remove_bom(line) for line in f), delimiter=',') for i, match_info in enumerate(reader): read_match_id = int(match_info["Match ID"]) if read_match_id not in self.matches_by_id: new_match = Match(read_match_id) self.matches.add(new_match) self.matches_by_id[new_match.id] = new_match with open("hero_ids.json") as f_heroes: heroes = json.load(f_heroes) for _, hero in heroes.items(): # Try and be safe from datdota hero names not quite matching localized names in json constants if ''.join([ j.lower() for j in hero["localized_name"] if j.isalpha() ]) == ''.join( [j.lower() for j in match_info["Hero"] if j.isalpha()]): new_match.add_hero(hero["id"]) break
def find_match_ids_odota(self): with open(self.query_file) as f: data = json.load(f) for match_info in data: if match_info["match_id"] not in self.matches_by_id: new_match = Match(match_info["match_id"]) self.matches.add(new_match) self.matches_by_id[new_match.id] = new_match new_match.add_hero(match_info["hero_id"])