| 4 | from abc import ABC, abstractmethod |
| 5 | |
| 6 | class 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 | |
| 22 | class DictCSVParser(CSVParser): |
| 23 | def __init__(self, types): |
nothing calls this directly
no outgoing calls
no test coverage detected