About This Page

This page contains programs that we created over the course of the project, along with descriptions of the programs.

Parser Code

California - Sonoma, Modoc and Plumas 2018 Counties Parser

ca_parser.zip

The parser, readme and requirement files for the Sonoma, Modoc and Plumas 2018 Counties parser.

Indiana - Multiple Counties 2018 Parser

in_parser.zip

The parser and readme files for the parser for multiple counties in Indiana.

Michigan - Muskegon 2018 County Parser

mo_parser.zip

The parser and readme files for the Muskegon county parser.

Table and Utilities Packages

Utilities Package

utilities.py

Utilities program that includes the following functions:

Table Package

table.py

Table package (used in our parsers). The table package contains Table and Row classes that output data in the proper format. The Row class is used to create an object that is representative of a row in the CSV and a Table represents a collection of rows that will output to a CSV. It has a function to add more rows to the table if it isn't already in the list that was input, and a function to convert the list to a CSV.

Other Helper Programs

add_party.py

add_party.py

Program to take of a csv with a candidate to party mapping (one column is the candidate, another column is the party), and insert it into another csv (where rows are missing party values, but contain candidate names). The program does this by first converting the mapping csv into a dictionary, and then reading the other csv and adding the party in whichever row it detects the candidate name.

What Was It Used For?

Some counties such as the California counties Sonoma, Modoc and Plumas do not contain the party information for each candidate. Instead, the candidate to party mapping was webscraped into a csv file. This program helped put the mapping information into the official Sonoma, Modoc and Plumas post-parser data csv.

data_cleaning.py

data_cleaning.py

Program to clean the csv from Open Elections into a usable form for our data visualization. Cleaning steps include percentage calculations, pivoting the table and more.

Validator Program

validate.py

Program used to validate csv data by calculating symmetric difference between CSVs and checking strings.