-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestsum.py
70 lines (62 loc) · 2.36 KB
/
testsum.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#find the average of environment temperature
def temp(db,id, date, session):
data = db.child("history").child(id).child(date).child(session).get()
data_dict = data.val()
sum=0
a=len(list(data_dict.values()))
for count in range (0,a-2):
sum=sum+list(data_dict.values())[int(count)]["envTemp"]
result=sum/(a-2)
print(result)
#db.child("history").child(id).child(date).child(session).update({"envtemp": result})
#find the average of heartrate
def heart_rate(db,id, date, session):
data = db.child("history").child(id).child(date).child(session).get()
data_dict = data.val()
sum=0
a=len(list(data_dict.values()))
for count in range (0,a-3):
sum=sum+list(data_dict.values())[int(count)]["hrtRate"]
result=sum/(a-3)
print(result)
#db.child("history").child(id).child(date).child(session).update({"heart rate": result})
#find the average of speed
def speed(db,id, date, session):
data = db.child("history").child(id).child(date).child(session).get()
data_dict = data.val()
sum=0
a=len(list(data_dict.values()))
for count in range (0,a-4):
sum=sum+list(data_dict.values())[int(count)]["spd"]
result=sum/(a-4)
print(result)
#db.child("history").child(id).child(date).child(session).update({"speed": result})
#find the average of humidity
def humidity(db,id, date, session):
data = db.child("history").child(id).child(date).child(session).get()
data_dict = data.val()
sum=0
a=len(list(data_dict.values()))
for count in range (0,a-5):
sum=sum+list(data_dict.values())[int(count)]["hum"]
result=sum/(a-5)
print(result)
#db.child("history").child(id).child(date).child(session).update({"humidity": result})
#find the average of body temperature
def body_temperature(db,id, date, session):
data = db.child("history").child(id).child(date).child(session).get()
data_dict = data.val()
sum=0
a=len(list(data_dict.values()))
for count in range (0,a-6):
sum=sum+list(data_dict.values())[int(count)]["bdyTemp"]
result=sum/(a-6)
print(result)
#db.child("history").child(id).child(date).child(session).update({"body temp": result})
# writes summary
def summary(db,id, date, session):
#temp(db,id, date, session)
#heart_rate(db,id, date, session)
#speed(db,id, date, session)
humidity(db,id, date, session)
#body_temperature(db,id, date, session)