From 06156d15e7b7415dd5e78c04c22dd60b1dfc4e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 20 Nov 2023 12:31:08 +0100 Subject: [PATCH] add output directory --- get_sheet.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/get_sheet.py b/get_sheet.py index 03f8b9e..013fd22 100644 --- a/get_sheet.py +++ b/get_sheet.py @@ -155,10 +155,10 @@ if __name__ == "__main__": fieldnames += sort_players_by_num_games(games) fieldnames += ['Other'] - with open('games.csv', 'w', newline='') as f: + with open('out/games.csv', 'w', newline='') as f: f.writelines([','.join(fieldnames), "\n"]) - with open('games.csv', 'a', newline='') as f: + with open('out/games.csv', 'a', newline='') as f: writer = csv.DictWriter(f, fieldnames=fieldnames) for game_id, entry in sorted(games.items()): bdrs, termination = analysis[game_id] @@ -186,10 +186,10 @@ if __name__ == "__main__": writer.writerow(row) fieldnames = ['Game ID'] + [str(i) for i in range(1, 16)] - with open('endgames.csv', 'w', newline='') as f: + with open('out/endgames.csv', 'w', newline='') as f: f.writelines([','.join(fieldnames), "\n"]) - with open('endgames.csv', 'a', newline='') as f: + with open('out/endgames.csv', 'a', newline='') as f: writer = csv.DictWriter(f, fieldnames=fieldnames) for game_id, endgame in sorted(endgames.items()): endgame['Game ID'] = "{}".format(game_id, game_id) @@ -199,9 +199,9 @@ if __name__ == "__main__": fieldnames = ['Game ID'] + [str(i) for i in range(1, 11)] for clue_modifier in range(-2, 3): filename = 'endgames{}.csv'.format(clue_modifier) - with open(filename, 'w') as f: + with open('out/' + filename, 'w') as f: f.writelines([','.join(fieldnames), "\n"]) - with open(filename, 'a') as f: + with open('out/' + filename, 'a') as f: writer = csv.DictWriter(f, fieldnames=fieldnames) for game_id, endgame in sorted(all_endgames.items()): # print(endgame) @@ -216,11 +216,11 @@ if __name__ == "__main__": print('processed file {}'.format(filename)) - x = pandas.read_csv(filename) - x.to_html('endgames_{}.html'.format(clue_modifier), escape=False) + x = pandas.read_csv('out/' + filename) + x.to_html('out/endgames_{}.html'.format(clue_modifier), escape=False) - a = pandas.read_csv("games.csv") - a.to_html("games.html", escape=False) + a = pandas.read_csv("out/games.csv") + a.to_html("out/games.html", escape=False) - b = pandas.read_csv('endgames.csv') - b.to_html("endgames.html", escape=False) + b = pandas.read_csv('out/endgames.csv') + b.to_html("out/endgames.html", escape=False)