def gen_group3(matchesdir, filename=None): ROWS_HEAD=BONUS_INFO_KEYS+EVALUATORS_KEYS+["config"] rows=[] for st in walk_statistics(matchesdir): for side in ["left", "right"]: st.side=side if not(st.team.lower().startswith("fcportugal")): # each row contains fcportugal data only continue teamdata=SortedDict() teamdata.update(bonus_info(st)) teamdata.update(evaluators(st)) t_config=discoverteamconfig(st.xml,st.side) teamdata["config"]=t_config # for confname in T_CONFIG_NAMES: # teamdata[confname]=t_config[confname] # another row. rows.append(teamdata) if filename is not None: with open(filename, "w") as f: f.write(";".join(ROWS_HEAD)+"\n") for row in rows: f.write(";".join([str(value) for _, value in row.iteritems()])) f.write("\n") return rows
def gen_group2(matchesdir, target_dir=None): ROWS_HEAD=BONUS_INFO_KEYS+STATISTICS14_KEYS teams={} for st in walk_statistics(matchesdir): for side in ["left", "right"]: st.side=side if st.team not in teams: teams[st.team]=[] teamdata=SortedDict() teamdata.update(bonus_info(st)) teamdata.update(statistics14(st)) # another row teams[st.team].append(teamdata) # write if target_dir is not None: if not os.path.isdir(target_dir): os.mkdir(target_dir) for teamname, teamdata in teams.iteritems(): fname=os.path.join(target_dir, teamname+".csv") with open(fname, "w") as f: f.write(";".join(ROWS_HEAD)+"\n") for row in teamdata: f.write(";".join([str(value) for _, value in row.iteritems()])) f.write("\n") return teams
def gen_group4(matchesdir, filename=None): ROWS_HEAD=BONUS_INFO_KEYS+EVALUATORS_KEYS+["config"]+["opponent"]+STATISTICS14_KEYS rows=[] for st in walk_statistics(matchesdir): fcp,other = teams_sides(st) teamsdata=SortedDict() st.side=fcp teamsdata.update(bonus_info(st)) teamsdata.update(evaluators(st)) t_config=discoverteamconfig(st.xml,st.side) teamsdata["config"]=t_config # for confname in T_CONFIG_NAMES: # teamsdata[confname]=t_config[confname] st.side=other teamsdata["opponent"]=st.team teamsdata.update(statistics14(st)) #another row rows.append(teamsdata) if filename is not None: with open(filename, "w") as f: f.write(";".join(ROWS_HEAD)+"\n") for row in rows: f.write(";".join([str(value) for _, value in row.iteritems()])) f.write("\n") return rows
def gen_group1(dir_, filename=None): ROWS_HEAD=BONUS_INFO_KEYS+STATISTICS14_KEYS rows=[] for st in walk_statistics(dir_): for side in ["left", "right"]: st.side=side teamdata=SortedDict() teamdata.update(bonus_info(st)) teamdata.update(statistics14(st)) # another row. rows.append(teamdata) if filename is not None: with open(filename, "w") as f: f.write(";".join(ROWS_HEAD)+"\n") for row in rows: f.write(";".join([str(value) for _, value in row.iteritems()])) f.write("\n") return rows