MCPcopy Index your code
hub / github.com/dabeaz-course/python-mastery / read_csv_as_instances

Function read_csv_as_instances

Solutions/3_3/reader.py:18–28  ·  view source on GitHub ↗

Read a CSV file into a list of instances

(filename, cls)

Source from the content-addressed store, hash-verified

16 return records
17
18def read_csv_as_instances(filename, cls):
19 '''
20 Read a CSV file into a list of instances
21 '''
22 records = []
23 with open(filename) as f:
24 rows = csv.reader(f)
25 headers = next(rows)
26 for row in rows:
27 records.append(cls.from_row(row))
28 return records

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
from_rowMethod · 0.45

Tested by

no test coverage detected