-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspector.py
More file actions
28 lines (24 loc) · 928 Bytes
/
inspector.py
File metadata and controls
28 lines (24 loc) · 928 Bytes
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
import csv
import typing
import inspection
class Inspector:
@staticmethod
def get_inspections() -> typing.Generator[inspection.Inspection, None, None]:
with open("data.csv", encoding="utf-8") as file:
reader = csv.reader(file, delimiter=",")
# Skip the first row, which is considered the header.
next(reader)
for _, line in enumerate(reader):
yield inspection.Inspection(
restaurant_id=line[0],
restaurant_name=line[1],
borough=line[2],
zipcode=line[5],
cuisine=line[7],
inspection_date=line[8],
violation_code=line[10],
violation_description=line[11],
score=line[13],
grade=line[14],
grade_date=line[15],
)