-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
57 lines (41 loc) · 1.24 KB
/
Copy pathprocess.py
File metadata and controls
57 lines (41 loc) · 1.24 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import time, json, os, datetime
output = "data/output.json"
def parse_ts(s):
return time.mktime(
datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S").timetuple())
files = []
for file in os.walk("data/"):
#print file[0]
for f in file:
if "snap_history.json" in f:
path = str(file[0]) + "/snap_history.json"
files.append(path)
data_received = {}
data_sent = {}
for file in files:
print "Reading ", file, len(data_received)
f = open(file)
data = json.loads( f.read() )
for i in data["Received Snap History"]:
#print i
key = None
if "Sender" in i:
key = i["Recipient"] + i["Sender"] + i["Created"]
else:
key = i["From"] + i["Created"]
i["ts"] = parse_ts(i["Created"].replace(" UTC",""))
data_received[key] = i
for i in data["Sent Snap History"]:
#print i
key = None
if "Sender" in i:
key = i["Recipient"] + i["Sender"] + i["Created"]
else:
key = i["To"] + i["Created"]
i["ts"] = parse_ts(i["Created"].replace(" UTC",""))
data_sent[key] = i
data = {
"Sent": data_sent,
"Received": data_received
}
open(output,"w+").write( json.dumps(data))