...
 
Commits (3)
import os.path
import collections
import csv
import unicodecsv as csv
import geojson
from distributed import make_map
......@@ -64,7 +64,7 @@ def load_election_data(filename, scaffold=False):
return races
votecounts = collections.defaultdict(lambda: 0)
with open(filename, 'rb') as f:
for row in csv.DictReader(f):
for row in csv.DictReader(f, encoding='utf-8-sig'):
votecounts[(
row['WARD'],
get_first(row, 'DIVISION', 'DIV'),
......
......@@ -145,7 +145,7 @@ def make_map(election_name, race_name, race_data, map_data,
patches = []
for color, choice in enumerate(choices):
patches.append(mpatches.Circle((0, 0), facecolor=get_color(color, colors=colors)))
labels.append('{} ({})'.format(choice, totals[choice]))
labels.append(u'{} ({})'.format(choice, totals[choice]))
for point in pointcollections[choice]:
points.append((point.x, point.y, get_color(color, colors=colors)))
......
......@@ -7,3 +7,4 @@ pyepsg==0.4.0
pytz==2019.1
s3-deploy-website==0.3.0
celery==4.3.0
unicodecsv==0.14.1
from string import maketrans
import datetime
import pytz
......@@ -7,7 +6,8 @@ eastern = pytz.timezone('US/Eastern')
def sanitize_name(name):
return name.translate(maketrans('#- !,&', '______')).lower()
replace_chars = '#- !,&'
return ''.join(char if char not in replace_chars else '_' for char in name).lower()
def uncapitalize(text):
......