Commit ed56d080 by Anne Rogers

one last merge

parents 5042bba6 e5e5d70c
Showing with 18 additions and 2 deletions
algorithms directory:
algorithms.py contains all the functions for constructing district plans by utilizing
the efficiency gap
drawing.py (must be run using Python2) creates a basemap of the United States and maps color-
coded tracts (the color corresponding to their district) onto the basemap using Networkx
reading_shapes directory:
get_combined.py contains functions to convert shapefiles of census tracts, determine which tracts
are connected to each other, and analyze demographic data to estimate the number of Republicans and Democrats in each district
location_api.py uses the GPS coordinates of census tracts to determine which state they are in
and sorts them accordingly
and sorts them accordingly, using the LocationIQ API
state_set_json_files contains the partially completed tracts as dictionaries created by
location_api.py
state_tracts_full_json_files contains the completed tract dictionaries created by get_combined.py
......
......@@ -4,7 +4,10 @@ import csv
def create_json_file(dictionary, path_file_name):
tract_str = str(dictionary)
if type(dictionary) != str:
tract_str = str(dictionary)
if type(dictionary) == str:
tract_str = dictionary
with open(path_file_name + ".json", 'w') as json_file:
json.dump(tract_str, json_file)
......@@ -22,4 +25,14 @@ def read_csv(path, file_name):
num_districts_states[row['state']] = row['num']
return num_districts_states
def color_csv(path, file_name):
with open(path + file_name) as csvfile:
colors_dict = {}
reader = csv.DictReader(csvfile)
count = 1
for row in reader:
colors_dict[count] = row['colors']
count += 1
return colors_dict
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment