-
Notifications
You must be signed in to change notification settings - Fork 0
/
overall.py
145 lines (115 loc) · 3.67 KB
/
overall.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python
"""
Anna University Grader -> Extracts grades from anna univ site
Improvement: Scraping grades to generate GPA, statistics
Feroze Naina
"""
from sqlite3 import *
from BeautifulSoup import BeautifulSoup
f = open('temp.html', 'w')
headers='''
<h1> Overall Results + Statistics </h1>
<p>'''
f.write(headers)
def branchwise(branch):
conn = connect('marks.db')
curs = conn.cursor()
#branch
f.write('''<table>
<style type="text/css">
tr.heading { background-color: DarkOrange; }
</style><b>'''+
branch+ '''</b><br /><br /> <i>Toppers</i><tr class="heading">
<td align=center>Regno</ td>
<td align=center>Name</ td>
<td align=center>GPA</ td></ tr>''')
curs.execute("SELECT roll,name,GPA FROM "+branch+" ORDER BY GPA DESC LIMIT 0,5")
for row in curs:
f.write('<tr>')
f.write('<td align=center>'+row[0]+'</ td>')
f.write('<td align=center>'+row[1]+'</ td>')
f.write('<td align=center>'+str(row[2])+'</ td>')
f.write('</ tr>')
#GPA Stats
f.write('''<table>
<style type="text/css">
tr.heading { background-color: DarkOrange; }
</style><b></b><br /><br /> <i>GPA Stats</i>
<tr class="heading">
<td align=center>Highest</ td>
<td align=center>Average</ td>
<td align=center>Lowest</ td></ tr><tr>''')
#max
curs.execute("SELECT MAX(GPA) FROM "+branch)
for max in curs:
f.write('<td align=center>'+str(max[0])+'</ td>')
#avg
curs.execute("SELECT AVG(GPA) FROM "+branch)
for avg in curs:
f.write('<td align=center>'+str(avg[0])+'</ td>')
#min
curs.execute("SELECT MIN(GPA) FROM "+branch)
for min in curs:
f.write('<td align=center>'+str(min[0])+'</ td>')
f.write('</ tr></table><br /><br /><br />')
conn.close()
def overall():
conn = connect('marks.db')
curs = conn.cursor()
#coll toppers
#Top 10 nerds
f.write('''<table>
<style type="text/css">
tr.heading { background-color: DarkOrange; }
</style><b>College Overall </b><br /><br /> <i>TOP 10 NERDS</i>
<tr class="heading">
<td align=center>Regno</ td>
<td align=center>Name</ td>
<td align=center>GPA</ td></ tr>''')
curs.execute("SELECT roll,name,GPA FROM overall ORDER BY GPA DESC LIMIT 0,10")
for row in curs:
f.write('<tr>')
f.write('<td align=center>'+row[0]+'</ td>')
f.write('<td align=center>'+row[1]+'</ td>')
f.write('<td align=center>'+str(row[2])+'</ td>')
#GPA Stats
f.write('''<table>
<style type="text/css">
tr.heading { background-color: DarkOrange; }
</style><b></b><br /><br /> <i>GPA Stats</i>
<tr class="heading">
<td align=center>Highest</ td>
<td align=center>Average</ td>
<td align=center>Lowest</ td></ tr><tr>''')
#max
curs.execute("SELECT MAX(GPA) FROM overall")
for max in curs:
f.write('<td align=center>'+ str(max[0])+'</ td>')
#avg
curs.execute("SELECT AVG(GPA) FROM overall")
for avg in curs:
f.write('<td align=center>'+ str(avg[0])+'</ td>')
#min
curs.execute("SELECT MIN(GPA) FROM overall")
for min in curs:
f.write('<td align=center>'+ str(min[0])+'</ td>')
f.write('</ tr></table><br /><br /><br />')
conn.close()
overall()
branchwise('EIE')
branchwise('ECE')
branchwise('EEE')
branchwise('CSE')
branchwise('IT')
branchwise('Civil')
branchwise('Mech')
branchwise('Prod')
f.close()
i = open('temp.html', 'r')
input=i.read()
soup = BeautifulSoup(input)
output=soup.prettify()
o=open('overalltemp.html', 'w')
o.write(output)
o.close()
i.close()