Last active
March 23, 2020 22:08
-
-
Save ajduberstein/ec3638fb54b0f0fbecf04bbd52370392 to your computer and use it in GitHub Desktop.
Script to remap county names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CORRECTIONS = { | |
"Stanislaus, CA": "Stanislaus County, CA", | |
"Monmouth, NJ": "Monmouth County, NJ", | |
"Stark, OH": "Stark County, OH", | |
"Bon Homme, SD": "Bon Homme County, SD", | |
"Orleans, LA": "Orleans Parish, LA", | |
"Ventura, CA": "Ventura County, CA", | |
"Jefferson, CO": "Jefferson County, CO", | |
"Pottawattamie, IA": "Pottawattamie County, IA", | |
"Nassau, FL": "Nassau County, FL", | |
"Noble, IN": "Noble County, IN", | |
"Solano, CA": "Solano County, CA", | |
"Island, WA": "Island County, WA", | |
"Calaveras, CA": "Calaveras County, CA", | |
"Adams, IN": "Adams County, IN", | |
"Loudoun, VA": "Loudoun County, VA", | |
"Thurston, WA": "Thurston County, WA", | |
"Fairfield, CT": "Fairfield County, CT", # Could be a town or a county | |
"Collier, FL": "Collier County, FL", | |
"Bucks, PA": "Bucks County, PA", | |
"Howard, IN": "Howard County, IN", | |
"Hillsborough, FL": "Hillsborough County, FL", | |
"Boone, IN": "Boone County, IN", | |
"Knox, NE": "Knox County, NE", | |
"Charles Mix, SD": "Charles Mix County, SD", | |
"Johnson, IN": "Johnson County, IN", | |
"Marin, CA": "Marin County, CA", | |
"Davison, SD": "Davison County, SD", | |
"Kitsap, WA": "Kitsap County, WA", | |
"Fayette, GA": "Fayette County, GA", | |
"St. Joseph, IN": "St. Joseph County, IN", | |
"Charlton, GA": "Charlton County, GA", | |
"Polk, OR": "Polk County, OR", | |
"Pennington, SD": "Pennington County, SD", | |
"Beadle, SD": "Beadle County, SD", | |
"Floyd, GA": "Floyd County, GA", | |
"Pasco, FL": "Pasco County, FL", | |
"Spotsylvania, VA": "Spotsylvania County, VA", | |
"DeKalb, GA": "DeKalb County, GA", | |
"Whatcom, WA": "Whatcom County, WA", | |
"Pierce, WI": "Pierce County, Wisconsin", | |
"Cuyahoga, OH": "Cuyahoga County, Ohio", | |
"Gregg, TX": "Gregg County, TX", | |
"Minnehaha, SD": "Minnehaha County, SD", | |
"Pinellas, FL": "Pinellas County, FL", | |
"Multnomah, OR": "Multnomah County, OR", | |
"Weber, Utah": "Weber County, Utah", | |
"Bon Homme, SD": "Bon Homme County, SD", | |
"Lake, IL": "Lake County, IL", | |
"Tarrant, TX": "Tarrant County, TX", | |
"Larimer, CO": "Larimer County, CO", | |
"Oakland, MI": "Oakland County, MI", | |
"Sullivan, TN": "Sullivan County, TN", | |
"Skagit, WA": "Skagit County, WA", | |
"Arapahoe, CO": "Arapahoe County, CO", | |
"San Benito, CA": "San Benito County, CA", | |
"Deschutes, OR": "Deschutes County, OR", | |
"Union, NJ": "Union County, NJ", # could be township or county | |
"Prince George's, MD": "Prince George's County, MD", | |
"Olmsted, MN": "Olmsted County, MN", | |
"Weber, UT": "Weber County, UT", | |
"Gwinnett, GA": "Gwinnett County, GA", | |
} | |
def text_replace(fname): | |
text = open(fname, 'r').read() | |
for k in CORRECTIONS.keys(): | |
text = text.replace(k, CORRECTIONS[k]) | |
f = open(fname, 'w') | |
f.write(text) | |
f.close() | |
files = [ | |
'time_series_19-covid-Confirmed.csv', | |
'time_series_19-covid-Deaths.csv', | |
'time_series_19-covid-Recovered.csv' | |
] | |
for f in files: | |
text_replace(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment