forked from Mercidaiha/IRT-Router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_sweep.py
More file actions
33 lines (27 loc) · 918 Bytes
/
parse_sweep.py
File metadata and controls
33 lines (27 loc) · 918 Bytes
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
32
33
#!/usr/bin/env python3
import argparse
import re
import csv
def main(input_file, output_file):
with open(input_file, 'r') as f:
content = f.read()
# Parse each block together to ensure values stay aligned
pattern = re.compile(
r'Alpha: ([\d.]+)\s+'
r'Performance: ([\d.]+)\s+'
r'Total Cost: ([\d.]+)',
re.MULTILINE
)
rows = pattern.findall(content)
# Write to CSV
with open(output_file, 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['alpha', 'performance', 'cost'])
writer.writerows(rows)
print(f"Wrote {len(rows)} rows to {output_file}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--input-file", help="Input file")
parser.add_argument("--output-file", help="Output file")
args = parser.parse_args()
main(args.input_file, args.output_file)