Parse bank PDF statements for bank operations.
SberParser
Designed to parse lines from Sberbank PDF statements and
convert them into Operation objects.
is_operation
classmethod
Use to filter strings that conform to the expected format of a bank transaction.
| Parameters: |
|
|---|
| Returns: |
|---|
Example
print(cls.is_operation("12.03.2024 14:22 456789 КАФЕ +100.00 12345.67"))
#> True
print(cls.is_operation("Some random text without a date"))
#> False
parse_main_line
classmethod
Parse a line into an Operation object if it matches the pattern.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
line = "12.03.2024 14:22 456789 КАФЕ +100.00 12345.67"
parser = SberParser()
operation = parser.parse_main_line(line)
print(operation.date)
#> datetime.date(2024, 3, 12)
parse_lines
classmethod
Parse a list of strings or a single string into a list of Operation objects.
Skip lines that do not match the expected format of a bank operation.
| Parameters: |
|---|
| Returns: |
|
|---|
Example
lines = "
12.03.2024 14:22 456789 КАФЕ +100.00 12345.67\n
Некорректная строка\n
13.03.2024 15:30 123456 МАГАЗИН -200.00 12145.67
"
parser = SberParser()
operations = parser.parse_lines(lines)
print(len(operations))
#> 2