CSV Loader

This commit is contained in:
Eden Kirin
2023-02-16 15:43:21 +01:00
parent 5caef41e80
commit c5a0008236
10 changed files with 603 additions and 0 deletions

21
lib/csv_loader/errors.py Normal file
View File

@ -0,0 +1,21 @@
class CSVValidationError(Exception):
"""Extended validation exception class containing additional attributes."""
def __init__(self, line_number: int, original_error: Exception) -> None:
self.line_number = line_number
self.original_error = original_error
def __str__(self) -> str:
return f"Error at line {self.line_number}: {self.original_error}"
class MappingStrategyError(Exception):
...
class HeaderNotSetError(MappingStrategyError):
detail = "Header must be set in order to use MappingStrategyByHeader"
class IndexOutOfHeaderBounds(MappingStrategyError):
detail = "Row value index out of header bounds"