-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtracker_plot.py
123 lines (90 loc) · 3.77 KB
/
tracker_plot.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from sys import argv
import time
import datetime
import os
import sqlite3 as lite
import sys
import pylab as pl
script, bodypartf, symptomf = argv
txt1 = open(bodypartf)
txt2 = open(symptomf)
eachline1 = txt1.readlines()
eachline2 = txt2.readlines()
i = len(eachline1)
j = len(eachline2)
intrinsicappendage = []
intrinsicsymptom = []
intrinsicintensity = []
intrinsictemperature = []
print "What's your name?"
username = raw_input()
print "Date of birth? YYYY-MM-DD"
dateofbirth = raw_input()
for b in range (0, i):
body = eachline1[b]
body = body.replace("\n","")
intrinsicappendage.append(body)
for b in range (0, j):
symptom = eachline2[b]
symptom = symptom.replace("\n","")
intrinsicsymptom.append(body)
print "Where does it hurt?"
extrinsicbodypart = raw_input()
starttimecomputer = time.time()
startdate = datetime.datetime.now().date()
startdate = str(startdate)
starttime = datetime.datetime.now().time()
print starttime
print "How does it hurt? ache, chills "
extrinsicsymptom = raw_input()
print "What is your temperature?"
extrinsictemperature = raw_input()
for b in range (0, 10):
temperature = 96 + float(b) * 10
intrinsictemperature.append(temperature)
print "On a scale of 1-10 how severe is your %s ?" % extrinsicsymptom
extrinsicintensity = raw_input()
for b in range (0, 10):
intensity = b
intrinsicintensity.append(intensity)
print "has this ended yet? yes/no"
ended = raw_input()
if ended == "yes":
duration = time.time()-starttimecomputer
endtime = datetime.datetime.now().time()
else:
duration = time.time()-starttimecomputer
endtime = datetime.datetime.now().time()
enddate = datetime.datetime.now().date()
enddate = str(enddate)
duration = str(duration)
starttime = str(starttime)
endtime = str(endtime)
extrinsicintensity = str(extrinsicintensity)
if 'extrinsictemperature' in locals():
extrinsictemperature = str(extrinsictemperature)
else:
extrinsictemperature = 98.66
extrinsictemperature = str(extrinsictemperature)
#outputfile1.write("INSERT INTO userx (firstname, dob) VALUES ('"+username+"','"+dateofbirth+"');")
#outputfile2.write("INSERT INTO event (user_id, start_date,
#start_time, end_date, end_time, duration, body_part, symptom,
#intensity, temperature) SELECT user_id,
#"+startdate+",'"+starttime+"',"+enddate+",'"+endtime+"',"+duration+",'"+extrinsicbodypart+"','"+extrinsicsymptom+"',"+extrinsicintensity+","+extrinsictemperature+"
#FROM userx WHERE userx.firstname = '"+username+"';")
#os.system("rm *.db")
checkfordb = os.system("ls sym-track.db")
con = lite.connect('sym-track.db')
with con:
cur = con.cursor()
if checkfordb > 0:
print 'making a new database sym-track.db'
cur.execute("CREATE TABLE userx(user_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, firstname VARCHAR, dob DATE)")
cur.execute("CREATE TABLE event( event_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, user_id INTEGER, start_date DATE, start_time VARCHAR, end_date DATE, end_time VARCHAR, duration FLOAT, body_part VARCHAR, symptom VARCHAR, intensity INTEGER, temperature FLOAT)")
cur.execute("INSERT INTO userx (firstname, dob) VALUES ('"+username+"','"+dateofbirth+"')")
cur.execute("INSERT INTO event (user_id, start_date, start_time, end_date, end_time, duration, body_part, symptom, intensity, temperature) SELECT user_id, "+startdate+",'"+starttime+"',"+enddate+",'"+endtime+"',"+duration+",'"+extrinsicbodypart+"','"+extrinsicsymptom+"',"+extrinsicintensity+","+extrinsictemperature+" FROM userx WHERE userx.firstname = '"+username+"'")
startdate_db = cur.execute("SELECT start_date from event")
intensity_db = cur.execute("SELECT intensity from event")
startdate_db = float(startdate_db.replace("|", " "))
intensity_db = float(intensity_db.replace("|", " "))
pl.plot(startdate_db, intensity_db)