-
Notifications
You must be signed in to change notification settings - Fork 2
/
jonay2000_to_csv.py
31 lines (23 loc) · 1.02 KB
/
jonay2000_to_csv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import csv
from pathlib import Path
from typing import List
from src.benchmarks.parser import JonathanCSVLayout
ROOT_DIR = Path("data")
if __name__ == "__main__":
for map_dir in ROOT_DIR.glob("./comparison_*"):
if not map_dir.is_dir():
continue
data_points: List[JonathanCSVLayout] = []
for file in map_dir.glob("./*.txt"):
algorithm = file.stem.removeprefix("results_")
for line in file.read_text().splitlines():
line_split = line.split(": ")
amount_of_agents = int(line_split[0])
runtimes = eval(line_split[1])
for i, runtime in enumerate(runtimes):
data_points.append((f"{map_dir.name}_{i}",
amount_of_agents, runtime, algorithm))
with open(map_dir / f"{map_dir.name}.csv", "w") as csv_file:
csv_writer = csv.writer(csv_file, delimiter=',')
csv_writer.writerows(data_points)
print(f"Written {map_dir}")