-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAKEMYTRIP City Wise.py
41 lines (38 loc) · 1020 Bytes
/
MAKEMYTRIP City Wise.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
import csv
d = {}
i=0
c=0
with open('G:/hotels-on-makemytrip/makemytrip_com-travel_sample.csv','r',encoding='utf-8') as csvfile:
read = csv.reader(csvfile,delimiter=',',quotechar='"')
for row in list(read):
try:
c+=1
city = row[1]
#area = row[0]
name = row[22]
mmt = row[16]
trip = row[18]
#site_rev = row[28]
rating = int(trip)*float(mmt)
if city not in d:
d[city] = {}
d[city][rating] = name
except:
continue
#print(d)
for i in list(d):
top =[]
keys = list(d[i].keys())
keys = sorted(keys,reverse=True)
print('-----------------------------------------\nFor',i,':\n','\nTotal Hotels: ',len(keys),'\nBest Hotel:',d[i][keys[0]])
try:
for j in range(5):
top.append(d[i][keys[j]])
print('\nTop 5 Hotels in order of their ranks:\n',top)
except:
print('\nTop',len(top),'Hotels order of their ranks:\n',top)
continue
#print("\nTotal Hotels: ",c)
z = input()
#keys = sorted(list(d[i].keys()))
#mt rating, tripadvisor rating