Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing an issue with regex recognizing certain characters #3

Merged
merged 1 commit into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bbva2pandas/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
\s
(\d\d/\d\d) #value date
\s*
([A-ZÑÁÉÍÓÚÜ\'\,\.\:\s]+) #concept
\s*
([\wÀ-ÿ .,:*%\'\/()\-\\]+?) #concept
\s+
(-?\d*.?\d*,\d*) #amount of the movement
\s*
(\d*.?\d*,\d*) #balance after movement
\s*
(\d*) # credit card number
\s*
([\d\wÑÁÉÍÓÚÜ \.\,\:\*\'\-\/\(\)]*) # subconcept
([\wÀ-ÿ .,:*%\'\/()\-\\]*) # subconcept
$''',
re.MULTILINE | re.IGNORECASE | re.VERBOSE
)
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pandas==1.2.1
numpy==1.20.2
pdftotext==2.1.5
pandas==1.4.0
numpy==1.22.1
pdftotext==2.2.2
2 changes: 2 additions & 0 deletions tests/data/pdf-content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ F.Oper. F.Valor Concepto
SALDO ANTERIOR - - - - - - - - - - - - - - - - - - - - - 0,00
05/08 05/08 TRANSFERENCIAS 42,00 42,00
X
12/08 10/08 COMPRA EN COMERCIO EXTRANJERO-COMISIÓN 3 % INCLUÍDA -8,79 13,55
LIDL BCN-CAN BATLL\ BARCELONA
Todos los importes de este extracto se expresan en: SALDO A NUESTRO FAVOR SALDO A SU FAVOR
EURO 42,00
F12345
Expand Down
8 changes: 6 additions & 2 deletions tests/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def test_movements_extraction(self):
with open('tests/data/pdf-content.txt') as f:
input = f.read()
movements = extractor.find_movements(input)
expected = [('05/08', '05/08', 'TRANSFERENCIAS ', '42,00', '42,00', '', 'X')]
self.assertEqual(1, len(movements))
expected = [('05/08', '05/08',
'TRANSFERENCIAS', '42,00',
'42,00', '', 'X'),
('12/08', '10/08', 'COMPRA EN COMERCIO EXTRANJERO-COMISIÓN 3 % INCLUÍDA', '-8,79', '13,55', '',
'LIDL BCN-CAN BATLL\ BARCELONA')]
self.assertEqual(2, len(movements))
self.assertEqual(expected, movements)