-
Notifications
You must be signed in to change notification settings - Fork 0
/
prasaresults.py
36 lines (32 loc) · 1.05 KB
/
prasaresults.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
32
33
34
35
36
import re
import os
def replace(file, pattern, subst):
file_handle = open(file, "r")
file_string = file_handle.read()
file_handle.close()
file_string = re.sub(pattern, subst, file_string)
file_handle = open(file, "w")
file_handle.write(file_string)
file_handle.close()
res = 2.5
file = "prasa.txt"
resfile = os.path.join(os.getcwd(), "prasaout.txt")
with open(file, "r") as infile, open(resfile, "w") as outfile:
datalines = []
for line in infile:
if line.startswith("End of trial"):
if not line.endswith(" 0\n"):
print(line)
outfile.write(line)
else:
pass
replace(resfile, "End of trial ", "")
replace(resfile, "final CC is ", "")
replace(resfile, "CCrange is ", "")
replace(resfile, "CCall is ", "")
replace(resfile, "(candidate for a solution)", "")
with open(resfile, "r") as file, open("strip.txt", "w") as out:
for line in file:
lineout = line.replace(" ()", "")
lineout = str(res) + ", " + lineout
out.write(lineout)