-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcondom_html_data_structures_creator.py
102 lines (59 loc) · 2.42 KB
/
condom_html_data_structures_creator.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
import datetime
import operator
from condom_structures import so_num, so_pct, so_options, total_so_responses
from condom_structures import confidence_num, confidence_pct, total_confidence_responses
so_table = '''
<table id = "t01" class = "inlineTable" style = "width: 50%; float: left;">
<caption style = "color: powderblue;"> Sexual Orientation Breakdown </caption>
<colgroup>
<col span = "1" style = "width: 70%;">
<col span = "1" style = "width: 15%;">
<col span = "1" style = "width: 15%;">
</colgroup>
<tr>
<th> Sexual Orientation </th>
<th> # </th>
<th> pct </th>
</tr>
'''
for orientation in so_num.keys():
so_table += "\n" + "<tr>" + "\n"
so_table += "<td>" + orientation + "</td>" + "\n"
so_table += "<td style = 'text-align: center;'>" + str(so_num[orientation]) + "</td>" + "\n"
so_table += "<td style = 'text-align: center;'>" + str((so_pct[orientation]*100))[:4] + "</td>" + "\n"
so_table += "</tr>" + "\n"
so_table += "</table>" + "\n"
confidence_table = '''
<table id = "t01" class = "inlineTable" style = "width: 50%; float: left;">
<caption style = "color: powderblue;"> Condom Confidence: "I feel confident I can use a condom correctly" </caption>
<colgroup>
<col span = "1" style = "width: 70%;">
<col span = "1" style = "width: 15%;">
<col span = "1" style = "width: 15%;">
</colgroup>
<tr>
<th> Response </th>
<th> # </th>
<th> pct </th>
</tr>
'''
for response in confidence_num.keys():
confidence_table += "\n" + "<tr>" + "\n"
confidence_table += "<td>" + response + "</td>" + "\n"
confidence_table += "<td style = 'text-align: center;'>" + str(confidence_num[response]) + "</td>" + "\n"
confidence_table += "<td style = 'text-align: center;'>" + str((confidence_pct[response]*100))[:4] + "</td>" + "\n"
confidence_table += "</tr>" + "\n"
confidence_table += "</table>" + "\n"
class Variables_needed:
timestamp = str(datetime.datetime.now())[:-7] #timestamp, in format "yyyy-mm-dd hh-mm-ss"
so_table = so_table
confidence_table = confidence_table
if __name__ == '__main__':
HTML_file_0 = open('quick_glance_draft.html', 'r')
html_new = HTML_file_0.read().format(p = Variables_needed())
HTML_file_1 = open('html_dashboard.html', 'w')
HTML_file_1.write("")
HTML_file_1.write(html_new)
HTML_file_0.close
HTML_file_1.close
pass