I hereby claim:
- I am migurski on github.
- I am migurski (https://keybase.io/migurski) on keybase.
- I have a public key whose fingerprint is 2D09 CC12 CFAF 908F 40D2 A4BC 6658 C0CD 757E 9D53
To claim this, I am signing this object:
-- | |
-- Table of available integers with a boolean column for when they're used up. | |
-- | |
DROP TABLE IF EXISTS brooklyn_integers; | |
CREATE TABLE brooklyn_integers (used BOOLEAN DEFAULT false NOT NULL, value BIGINT NOT NULL); | |
CREATE INDEX brooklyn_integers_used ON brooklyn_integers (used); | |
CREATE UNIQUE INDEX brooklyn_integers_value ON brooklyn_integers (value); | |
-- | |
-- Request a single unused integer and mark it used. |
''' Convert ward-level result CSVs from OpenElections to tabular format. | |
''' | |
import gzip, csv, collections, sys, itertools | |
def key1(row): | |
''' Outer key is the county and ward. | |
''' | |
return row['county'], row['ward'] | |
def key2(row): |
import psycopg2, csv, math | |
with psycopg2.connect('postgres:///redistrict_nc') as conn: | |
with conn.cursor() as db: | |
for year in ['2016', '2014', '2012']: | |
with open(f'{year}-4.txt') as in_file, open(f'{year}-5.txt', 'w') as out_file: | |
in_rows = csv.DictReader(in_file, dialect='excel-tab') | |
out_fields = in_rows.fieldnames + ['Non-Hispanic White', | |
'Non-Hispanic White, Error', 'College', 'College, Error', |
''' Convert precinct-level result CSVs from OpenElections to tabular format. | |
''' | |
import gzip, csv, collections, sys, itertools | |
def key1(row): | |
''' Outer key is the county and precinct. | |
''' | |
return row['parent_jurisdiction'], row['jurisdiction'] | |
def key2(row): |
from osgeo import ogr | |
import requests, zipfile, io, tempfile, shutil, os, sys, csv, math, collections | |
state_codes = { | |
'01': 'AL', '31': 'NE', '02': 'AK', '32': 'NV', '04': 'AZ', '33': 'NH', | |
'05': 'AR', '34': 'NJ', '06': 'CA', '35': 'NM', '08': 'CO', '36': 'NY', | |
'09': 'CT', '37': 'NC', '10': 'DE', '38': 'ND', '11': 'DC', '39': 'OH', | |
'12': 'FL', '40': 'OK', '13': 'GA', '41': 'OR', '15': 'HI', '42': 'PA', | |
'16': 'ID', '72': 'PR', '17': 'IL', '44': 'RI', '18': 'IN', '45': 'SC', | |
'19': 'IA', '46': 'SD', '20': 'KS', '47': 'TN', '21': 'KY', '48': 'TX', |
I hereby claim:
To claim this, I am signing this object: