-
Notifications
You must be signed in to change notification settings - Fork 6
/
india-test-view.py
69 lines (47 loc) · 1.48 KB
/
india-test-view.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
# Blank Python
import scraperwiki
from pygooglechart import PieChart3D
from pygooglechart import PieChart2D
from hashlib import md5
import string
import cgi, os
scraperwiki.sqlite.attach( 'elections_in_uttar_pradesh_-_india' )
select_all = 'constituency FROM "uttar-pradesh-elections" LIMIT 10'
#all = scraperwiki.sqlite.select(select_all)
#for a in all:
# selection = '* FROM "uttar-pradesh-elections" WHERE "constituency" LIKE "' + a['constituency'] + '"'
#exit()
select = '* FROM "uttar-pradesh-elections" WHERE "constituency" LIKE "Alapur%"'
this = scraperwiki.sqlite.select(select)
print '''
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Party');
data.addColumn('number', 'Votes');
data.addRows([
'''
for t in this:
print '["'+t['party']+' - ' + t['candidate'] + '",'+t['votes']+'],'
print '''
]);
var options = {
title:'''
print '"Agra Cantt."'
print '''
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
'''