-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_data.py
More file actions
42 lines (34 loc) · 867 Bytes
/
parse_data.py
File metadata and controls
42 lines (34 loc) · 867 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
32
33
34
35
36
37
38
39
40
41
42
import pprint
import json
filename = "static/temp_logs.txt"
keys = ["temp_0", "temp_1", "temp_2", "temp_3", "temp_4", "temp_5"]
mins = {}
maxs = {}
def raw_values():
f = open(filename)
for line in f.readlines():
data = json.loads(line)
clean_values = []
for key in data.keys():
val = data[key]
if val != None and key in keys:
val = sum(val)/len(val)
# default values
if key not in mins:
mins[key] = 10000
if key not in maxs:
maxs[key] = 0
mins[key] = min(mins[key], val)
maxs[key] = max(maxs[key], val)
print "MINIMUMS"
pprint.pprint(mins)
print "\n\nMAXIMUMS"
pprint.pprint(maxs)
def observations():
f = open(filename)
for line in f.readlines():
data = json.loads(line)
if len(data.keys()) == 2:
print data
raw_values()
observations()