MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / CSVParser

Class CSVParser

Solutions/3_8/reader.py:6–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4from abc import ABC, abstractmethod
5
6class CSVParser(ABC):
7
8 def parse(self, filename):
9 records = []
10 with open(filename) as f:
11 rows = csv.reader(f)
12 headers = next(rows)
13 for row in rows:
14 record = self.make_record(headers, row)
15 records.append(record)
16 return records
17
18 @abstractmethod
19 def make_record(self, headers, row):
20 pass
21
22class DictCSVParser(CSVParser):
23 def __init__(self, types):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected