-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
25 lines (22 loc) · 926 Bytes
/
parse.py
File metadata and controls
25 lines (22 loc) · 926 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
import os
path = "output"
folders = sorted(os.listdir(path))
for i in folders:
log_file_path = os.path.join(path, i, "log.txt")
highest_prec1 = 0.0
save_line =""
# Open the log file and read its contents line by line
with open(log_file_path, 'r') as file:
for line in file:
# Split the line into words based on spaces
words = line.split()
# Find the index of 'Prec@1' in the words list
prec1_index = words.index('Prec@1')
# Extract the Prec@1 value and convert it to a float
prec1_value = float(words[prec1_index + 1])
# Update the highest_prec1 value if the current value is higher
if prec1_value > highest_prec1:
highest_prec1 = prec1_value
save_line = line
# Print the highest Prec@1 value
print(f"{i}; Highest Prec@1 value: {highest_prec1}; {save_line}")