-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathparse_logs.py
More file actions
26 lines (21 loc) · 1.03 KB
/
parse_logs.py
File metadata and controls
26 lines (21 loc) · 1.03 KB
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
import re
import glob
import itertools
columns = []
for log_file in sorted(glob.glob('logs/*.txt')):
f = open(log_file, 'r').read()
res = []
res.append((log_file + '_step', log_file + '_target_task_error', log_file + '_multi_task_error'))
for i, target_task_error, target_task_loss, multi_task_error, multi_task_loss, curricilum, curriculum_point_error, curriculum_point_loss \
in re.findall('EVAL_PARSABLE: (\d+),([-+]?\d*\.\d+|\d+),(-?\ *[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?),([-+]?\d*\.\d+|\d+),(-?\ *[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?),(\d+|\(.*\)),([-+]?\d*\.\d+|\d+|None),(-?\ *[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?|None)\n', f):
res.append((i, target_task_error, multi_task_error))
columns.append(res)
print map(len, columns)
f = open('parsed_log_files.csv', 'w')
for t in itertools.izip_longest(*columns, fillvalue=(None, None, None)):
line = ''
for t_ in t:
for column in t_:
line += (str(column) if column is not None else '') + ','
f.write(line[:-1] + '\n')
f.close()