def kv_counts_from_file(file_name, kv_counts): pairs = [] for line in open(file_name): line = line.rstrip() key_str, count_str = line.split("\t") count = int(count_str) kv_str, range_str = key_str.split(" ") key, value = kv_str.split("=") key = dota_values.get_game_mode(int(value)) start_range, stop_range = map(int, range_str[1:len(range_str)-2].split("-")) kv_counts[key][start_range / INTERVAL] += count
def translate_values(kv_counts): for field, value_counts in kv_counts.items(): if(field == "game_mode"): new_dict = {} for value, counts in value_counts.iteritems(): new_dict[get_game_mode(int(value))] = counts kv_counts[field] = new_dict elif(field == "lobby_type"): new_dict = {} for value, counts in value_counts.iteritems(): new_dict[get_lobby_type(int(value))] = counts kv_counts[field] = new_dict