-
Notifications
You must be signed in to change notification settings - Fork 0
/
countClosedRests.py
40 lines (34 loc) · 1.04 KB
/
countClosedRests.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
import pickle
from bs4 import BeautifulSoup
import sys
from progressbar import *
import time
from specialFunctions import NYCzips,getPercentDiff
countTotal = 0
souper = BeautifulSoup('html')
widgets = ['Running: ', Percentage(), ' ',
Bar(marker='0',left='[',right=']'),
' ', ETA()]
for indexz, zipcode in enumerate(NYCzips):
goodlist = []
thisCount = 0
exec("inFile=open('%s','r')" % (str(zipcode)+'results2'))
exec("outFile=open('%s','w')" % (str(zipcode)+'results2woClosed'))
locations = pickle.load(inFile)
inFile.close()
pbar = ProgressBar(widgets=widgets, maxval=len(NYCzips))
pbar.start()
for index,location in enumerate(locations):
pbar.update(indexz+1)
soup = BeautifulSoup(location,'xml')
if soup.business_operation_status.string == unicode(0):
thisCount+=1
else:
goodlist.append(location)
print str(thisCount)+' restaurants closed in zip: '+str(zipcode)
countTotal+=thisCount
pickle.dump(goodlist,outFile)
del goodlist
outFile.close()
pbar.finish()
print str(countTotal)+' total restaurants closed in data set'