-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmany_parse.py
More file actions
31 lines (26 loc) · 771 Bytes
/
many_parse.py
File metadata and controls
31 lines (26 loc) · 771 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
import json
DICT_COMMON = {}
def parse_json(json_file: str) -> dict:
jdict = {}
with open(json_file, "r") as f:
for l in f:
j = json.loads(l)
jdict[j.get("timestamp")] = j.get("message")
return jdict
def parse_out(out_file: str) -> dict:
odict = {}
with open(out_file, "r") as f:
for l in f:
j = l.split()
odict[j[0]] = j[3]
return odict
def dict_iterator(d1: dict, d2: dict) -> None:
for k,v in d1.items():
if "Eclipse" in v:
DICT_COMMON[k] = v
for k,v in d2.items():
if "wl" in v:
DICT_COMMON[k] = v
print(DICT_COMMON)
if __name__=="__main__":
dict_iterator(parse_json("logging-0.json"), parse_out("syslog_parsed.out"))