-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopParkingOffenders.py
46 lines (32 loc) · 1.08 KB
/
TopParkingOffenders.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 22 21:08:22 2017
@author: yorranshellwattson
"""
import csv
tickets = {}
plateID = {}
issuedate = {}
state = {}
carType = {}
f = open("Parking.csv")
reader = csv.DictReader(f)
for row in reader:
summonsnum = row["Summons Number"]
tickets[summonsnum] = tickets.get(summonsnum, 0) + 1
plate = row["Plate ID"]
plateID[plate] = plateID.get(plate, 0) + 1
date = row["Issue Date"]
issuedate[date] = issuedate.get(date, 0) + 1
regstate = row ["Registration State"]
state[regstate]= state.get(regstate, 0) + 1
car = row ["Plate Type"]
carType[car] = carType.get(car, 0) + 1
f.close()
worstPlateID = sorted(plateID, key = plateID.__getitem__, reverse=True)
worstState = sorted(state, key = state.__getitem__, reverse=True)
worstCarType = sorted(carType, key = carType.__getitem__, reverse=True)
#Top 10 Worst Offenders by ID, State, Car Type
for i in range(10):
print("Plate ID", worstPlateID[i], "has", plateID[worstPlateID[i]], "tickets.")