(self, filename)
| 8 | class CSVParser(ABC): |
| 9 | |
| 10 | def parse(self, filename): |
| 11 | records = [] |
| 12 | with open(filename) as f: |
| 13 | rows = csv.reader(f) |
| 14 | headers = next(rows) |
| 15 | for rowno, row in enumerate(rows, start=1): |
| 16 | try: |
| 17 | record = self.make_record(headers, row) |
| 18 | records.append(record) |
| 19 | except ValueError as e: |
| 20 | log.warning('Row %d: Bad row: %s', rowno, row) |
| 21 | log.debug('Row %d: Reason: %s', rowno, e) |
| 22 | |
| 23 | return records |
| 24 | |
| 25 | @abstractmethod |
| 26 | def make_record(self, headers, row): |
no test coverage detected