-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthInspection.py
More file actions
83 lines (64 loc) · 1.96 KB
/
HealthInspection.py
File metadata and controls
83 lines (64 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#Get modules/libraries
import csv
import re
import sys
import pylab
from pylab import *
#Tabluate reports by facilityType
def facilityType():
#import Chicago health inspection data
healthData = open('food.csv')
#Set up data storage
facilityTypeIndex = {}
riskLevelIndex = {};
# Organize Data by Type
for row in csv.DictReader(healthData):
if row['Facility Type'] not in facilityTypeIndex:
facilityTypeIndex[row['Facility Type']] = []
facilityTypeIndex[row['Facility Type']].append(row)
# Log all resteraunts
print(len(facilityTypeIndex['Restaurant']))
#Sort resteraunts by number of issues
sortedFacilities = sorted(facilityTypeIndex, key=len)
#print out ten facility types with most complaints
print(sortedFacilities[0:10])
#Tabulate reports by their risk level
def riskLevel():
healthData = open('food.csv')
#Organize Data by Risk Level
for row in csv.DictReader(healthData):
if row['Risk'] not in riskLevelIndex:
riskLevelIndex[row['Risk']] = []
riskLevelIndex[row['Risk']].append(row)
#open dataset for reading
#Tabulate reports for subway by their risk level
def subway():
healthData = open('food.csv')
#make subway array holder
subway = {}
#Get all subway data
for row in csv.DictReader(healthData):
if row['DBA Name'] == 'SUBWAY SANDWHICH' or row['AKA Name'] == 'SUBWAY':
if row['Risk'] not in subway:
subway[row['Risk']] = []
subway[row['Risk']].append(row)
for risk in subway:
print(risk, len(risk))
pylab.pie([23, 47, 62])
xlabel('hi mom!')
pylab.show()
def parseNotes(line):
interestingFeatures = ['rodent', 'droppings']
#Calls various above functions
def main():
if len(sys.argv) !=2:
print 'usagage: HealthInspetion.py {--subway | --risk | --facilityType}'
option = sys.argv[1]
if option == '--subway':
subway()
elif option == '--risk':
riskType()
elif option == '--facilityType':
facilityType()
if __name__ == '__main__':
main()