This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# creates json for sankey from matrix row->column | |
# 10 -> 3 | |
import json | |
import csv | |
# read into data | |
out = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//join election results with list of all stations and output lat,lng,results into json | |
// we want to get such structure (similar): | |
// {"name": "\u00dast\u00ed nad Labem-0", "winner": "Zeman", "coordinates": ["14.036975", "50.660316"], "id": "554804-0", "population": {"p9": "16025", "p6": "21011", etc. }, "party" : {"p1": "Úsvit", etc. }, "names": ["p1": "Talaš ..", etc.}}, | |
$handle_results = fopen('zlin_stations.csv','r'); | |
$handle_geo = fopen('okrsky_geo_adj.csv','r'); | |
$handle_out = fopen('zlin.json','w'); | |
// read results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//join election results with list of all stations and output lat,lng,results into json | |
// we want to get such structure (similar): | |
// {"name": "\u00dast\u00ed nad Labem-0", "winner": "Zeman", "coordinates": ["14.036975", "50.660316"], "id": "554804-0", "population": {"p9": "16025", "p6": "21011", etc. }, "party" : {"p1": "Úsvit", etc. }, "names": ["p1": "Talaš ..", etc.}}, | |
$handle_results = fopen('zlin_stations.csv','r'); | |
$handle_geo = fopen('okrsky_geo_adj.csv','r'); | |
$handle_out = fopen('zlin.json','w'); | |
// read results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# | |
import pickle | |
import csv | |
import json | |
with open("responsesw", 'rb') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# calculates the transfers, 2 rounds | |
# using weights from R | |
import json | |
import csv | |
# read into data | |
i = 0 |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"name": "\u00dast\u00ed nad Labem-0", "winner": "Zeman", "coordinates": ["14.036975", "50.660316"], "classname": "zeman", "id": "554804-0", "population": {"p9": "16025", "p6": "21011"}}, {"name": "Praha 3-0", "winner": "Schwarzenberg", "coordinates": ["14.454167", "50.084444"], "classname": "schwarzenberg", "id": "500097-0", "population": {"p9": "21749", "p6": "10244"}}, {"name": "Opava-0", "winner": "Zeman", "coordinates": ["17.90251", "49.938873"], "classname": "zeman", "id": "505927-0", "population": {"p9": "11415", "p6": "15536"}}, {"name": "Plze\u0148 1-0", "winner": "Schwarzenberg", "coordinates": ["13.3714008", "49.7669356"], "classname": "schwarzenberg", "id": "545970-0", "population": {"p9": "11984", "p6": "11443"}}, {"name": "Brno-sever-0", "winner": "Schwarzenberg", "coordinates": ["16.627121", "49.214233"], "classname": "schwarzenberg", "id": "551031-0", "population": {"p9": "12400", "p6": "9926"}}, {"name": "Praha 1-0", "winner": "Schwarzenberg", "coordinates": ["14.411111", "50.086389"], "clas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import json | |
import csv | |
import string | |
data = [] | |
i = 0 | |
with open("okrsky_geo_adj.csv","r") as fin: | |
finreader = csv.reader(fin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# calculates 18 groups | |
import pickle | |
import csv | |
with open("responses0", 'rb') as f: | |
responses = pickle.load(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"features":[{"id":"1207","winner":"Bachelet","classname":"bachelet","population":{"p6":"69751","p9":"37854"},"coordinates":["-70.5666667","-33.6166667"],"name":"PUENTE ALTO"},{"id":"1160","winner":"Bachelet","classname":"bachelet","population":{"p6":"55859","p9":"34120"},"coordinates":["-70.7666667","-33.5166667"],"name":"MAIPU"},{"id":"1276","winner":"Bachelet","classname":"bachelet","population":{"p6":"50000","p9":"24209"},"coordinates":["-71.65729","-35.430647"],"name":"TALCA"},{"id":"1211","winner":"Bachelet","classname":"bachelet","population":{"p6":"47733","p9":"27729"},"coordinates":["-70.7","-33.5833333"],"name":"SAN BERNARDO"},{"id":"1226","winner":"Bachelet","classname":"bachelet","population":{"p6":"38966","p9":"23653"},"coordinates":["-70.738965","-34.168052"],"name":"RANCAGUA"},{"id":"1307","winner":"Bachelet","classname":"bachelet","population":{"p6":"38291","p9":"22906"},"coordinates":["-72.102423","-36.609354"],"name":"CHILLAN"},{"id":"1425","winner":"Bachelet","classname":"bachelet","populat |