forked from learnpythonru/basic_exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsc_bus.py
More file actions
21 lines (18 loc) · 751 Bytes
/
msc_bus.py
File metadata and controls
21 lines (18 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import csv
with open('msc_bus.csv', encoding='utf-8') as file:
headers = csv.DictReader(file, delimiter=';')
for header in headers:
fields = header.values()
break
src = csv.DictReader(file, delimiter=';', fieldnames=fields)
lst = []
for string in src:
street = string['Описание места расположения объекта']
if street:
try:
comma = street.index(',')
lst.append(street[:comma])
except ValueError:
lst.append(street)
print('Количество остановок:', len(lst))
print('Улица, на которой больше всего остановок:', max(lst, key=lst.count))