Skip to content

Instantly share code, notes, and snippets.

View alexanderankin's full-sized avatar

David Ankin alexanderankin

View GitHub Profile
import errno, os, csv
"""
the pattern is that when a line starts with "County"
the next line defines the length of a vector
record the matrix
when a line starts with totals, start looking for a county line
dfa:
lfc
first line
@alexanderankin
alexanderankin / 1.csv
Last active June 8, 2019 20:45
2019 Allegheny County Primary Elections - from the processed text file
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 5 in line 1.
""
County,Registered Voters,Ballots Cast,Voter Turnout,
ALEPPO,1369,223,16.29%
ASPINWALL DIST 1,885,174,19.66%
ASPINWALL DIST 2,607,133,21.91%
ASPINWALL DIST 3,872,182,20.87%
AVALON WARD 1,1122,117,10.43%
AVALON WARD 2 DIST 1,721,110,15.26%
AVALON WARD 2 DIST 2,476,69,14.50%
AVALON WARD 3 DIST 1,329,42,12.77%
@alexanderankin
alexanderankin / Allegheny County Wards and Districts
Last active August 28, 2019 19:15
2017 Allegheny County Wards and subdivisions
# Allegheny County Wards and Districts
@alexanderankin
alexanderankin / Philadelphia Political Maps.md
Last active June 2, 2019 20:39
Philadelphia Political Maps

Philly Political Maps

This gist contains the maps for Philadelphia Council, Wards, and ward subdivisions (precincts).

Sources

@alexanderankin
alexanderankin / fix_csv.py
Created August 2, 2019 21:31
CSV Fixing script
#!/usr/bin/env python3
"""
This script is useful only for csv files with no fields containing special or
escaped characters in the first NUM_TRIVIAL_FIELDS fields.
Otherwise, the in[put]line.split(",") will break, and is a bad idea.
this script produces a file which can be imported into mysql with:
LOAD DATA LOCAL INFILE 'out.csv' INTO TABLE my_existing_table
@alexanderankin
alexanderankin / Match_Reach_to_VF.sql
Created August 2, 2019 22:52
Scripts to process Reach Exports
-- put "new" data with the rest of the reach data
select
matches.IDNumber,
reach_data.ReachID,
reach_data.AddedTimestamp,
reach_data.LastReachedTimestamp,
reach_data.LastReachedbyUserName,
reach_data.AutoAppliedTag,
reach_data.CampaignTags,
reach_data.FirstName,
@alexanderankin
alexanderankin / README.md
Last active August 8, 2019 00:45
Useful scripts for importing CSV Files into SQL database.

CSV SQL Scripts

Useful scripts for importing CSV Files into SQL database.

For install, clone repo + make symlink.

@alexanderankin
alexanderankin / Regions Readme.md
Last active September 12, 2019 14:42
Regions for Countywide Campaign

Regions of Allegheny County

@alexanderankin
alexanderankin / MA Maps Masterlist.md
Last active September 22, 2019 10:49
Massachusetts Electoral Map Masterlist

E Maps Masterlist

  • state house lower map
  • state house upper map
  • precints by town list
  • all precincts is 22MB file, here
@alexanderankin
alexanderankin / districts.geojson
Last active September 22, 2019 09:43
MA House SLDL
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.