-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv.py
69 lines (57 loc) · 1.38 KB
/
csv.py
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
"""
This script tells you where not to eat
"""
import sys
import os
import csv
import re
USERNAME = os.getlogin()
if sys.platform.startswith('win32'):
p = 'C:/users/'+USERNAME+'/Desktop/'
elif sys.platform.startswith('darwin'):
p = '/Volumes/MyDrive/Users/'+USERNAME+'/Desktop/'
else:
print('Your Operating System is not Supported')
sys.exit(1)
fn = p+'DOHMH_New_York_City_Restaurant_Inspection_Results.tsv'
try:
f = open(fn)
except FileNotFoundError:
print("Go to the following link > export > TSV for excel > and save the file to your desktop\n")
print("https://data.cityofnewyork.us/Health/DOHMH-New-York-City-Restaurant-Inspection-Results/xx67-kt59")
sys.exit(1)
count = 0
try:
r = int(input("What is your zip code? "))
except:
print("That's not a zipcode")
sys.exit(1)
for i in str(r):
count += 1
if count == 4:
print("That zipcode is not in NYC")
sys.exit(1)
elif count != 5:
print("That is not a zip code")
sys.exit(1)
if r >11697:
print("That zipcode is not in NYC")
sys.exit(0)
br = []
for l in f:
s = l.split("\t")
if l[0:5] == 'CAMIS' or str(s[5]) == 'N/A':
continue
if s[13] == '':
s[13] = 0
if r == int(s[5]):
if int(s[13]) >= 30 and \
bool(re.findall("rat|roach|mice|flies",str(s[11]))):
br.append(s[1])
if br == []:
print("That zipcode is not in NYC")
sys.exit(1)
print("I would avoid these restaurants:")
for i in br:
print(i)
sys.exit(0)