-
Notifications
You must be signed in to change notification settings - Fork 0
/
zomato_fun.py
63 lines (42 loc) · 1.51 KB
/
zomato_fun.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
import json
def zomato(x):
a = open('G:/zomato-restaurants-data/'+x,'r',encoding='utf-8')
zomato = json.load(a)
a.close()
d={}
c = 0
top = []
maxs = 0
for i in zomato:
for j in range(20):
try:
names = i['restaurants'][j]['restaurant']['name']
votes = i['restaurants'][j]['restaurant']['user_rating']['votes']
aggre = i['restaurants'][j]['restaurant']['user_rating']['aggregate_rating']
city = i['restaurants'][j]['restaurant']['location']['city']
c+=1
d[float(aggre)*int(votes)] = names+','+city
if float(aggre)*int(votes)>maxs:
maxs = float(aggre)*int(votes)
best = names
becity = city = i['restaurants'][j]['restaurant']['location']['city']
except:
continue
resto = zomato[0]['restaurants']
#print(d)
print('\nTotal Restaurants: ',c)
print('Best Restaurant: ',best,',',becity)
#----------------------------------------------------------------------
#list_of_keys = list(d.keys())
#print(max(list_of_keys))
#TOP 5
list_of_keys = list(d.keys())
while len(top)!=5:
m = max(list_of_keys)
top.append(d[m])
list_of_keys.remove(m)
print('\nTop 5 Restaurants in order of Rank:\n',top)
while True:
y = input('\nEnter Filename\n->')
zomato(y)
z = input()