-
Notifications
You must be signed in to change notification settings - Fork 0
/
regex_sealfs.py
39 lines (26 loc) · 981 Bytes
/
regex_sealfs.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
37
38
39
import re
import glob
import csv
number_re = re.compile(r'\d+\.\d+')
openvpn_re = re.compile(r'openvpn')
sealfs_re = re.compile(r'^.+sealfs_write.+$', re.MULTILINE)
files = glob.glob("./Summit/*sealfs_ftrace*.txt")
for file_path in files:
filename = re.split(r'[/\.]', file_path)[-2]
filename_w_ext = re.split(r'[/]', file_path)[-1]
path = file_path[:-len(filename_w_ext)]
output_file_path = path + filename + "_parsed.csv"
output_file = open(output_file_path, "w")
csv_writer = csv.writer(output_file)
file = open(file_path, "r")
all_text = file.read()
matches = sealfs_re.findall(all_text)
for match in matches:
if openvpn_re.search(match) is not None:
continue
time = number_re.findall(match)
if len(time) == 0:
continue
csv_writer.writerow(['sealfs_write', time[0]])
output_file.close()
file.close()