Skip to content

Instantly share code, notes, and snippets.

@mhornbacher
Last active August 21, 2019 00:54
Show Gist options
  • Save mhornbacher/d8357e218f4d1725cc80b12fb178f06b to your computer and use it in GitHub Desktop.
Save mhornbacher/d8357e218f4d1725cc80b12fb178f06b to your computer and use it in GitHub Desktop.
Parser for Healthcare_Associated_Infections.csv file
import csv
cities = dict()
counties = dict()
hosptials = dict()
with open('Healthcare_Associated_Infections.csv', 'r') as f:
reader = csv.reader(f, delimiter=",")
for i, row in enumerate(reader):
if i == 0:
continue
city = row[3]
county = row[6]
hospital = row[1]
if city in cities:
cities[city] += 1
else:
cities[city] = 1
if county in counties:
counties[county] += 1
else:
counties[county] = 1
if hospital in hosptials:
hosptials[hospital] += 1
else:
hosptials[hospital] = 1
print("Total Cities: " + str(len(cities)))
print("Total counties: " + str(len(counties)))
print("Total Hospitals: " + str(len(hosptials)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment