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

Execute Default Use Case (za.absa.cheque) #55

Open
sendublon opened this issue Mar 28, 2022 · 2 comments
Open

Execute Default Use Case (za.absa.cheque) #55

sendublon opened this issue Mar 28, 2022 · 2 comments

Comments

@sendublon
Copy link

sendublon commented Mar 28, 2022

Hello,
I have installed the software, got an absa cheque template statement but when I try to execute the software I get the below error.
I understood how to create a config file for the statement of my bank (the principle at least) but I cannot even run the default example.
Anyone could help?
Many thanks

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3621, in get_loc
return self._engine.get_loc(casted_key)
File "pandas/_libs/index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Debit Amount'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/psr", line 8, in
sys.exit(cli())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pdf_statement_reader/init.py", line 80, in pdf2csv
df = parse_statement(input_filename, config)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pdf_statement_reader/parse.py", line 104, in parse_statement
clean_numeric(statement, config)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pdf_statement_reader/parse.py", line 50, in clean_numeric
df[col] = df[col].apply(format_negatives)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/core/frame.py", line 3505, in getitem
indexer = self.columns.get_loc(key)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3623, in get_loc
raise KeyError(key) from err
KeyError: 'Debit Amount'

@lalebarde
Copy link

lalebarde commented Sep 15, 2023

I have the same error:

$ psr pdf2csv -c fr.LCL.releve_pdf COMPTEDEDEPOTS_04045009604_20210806.pdf 
Traceback (most recent call last):
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'DEBIT'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/alain/anaconda3/bin/psr", line 8, in <module>
    sys.exit(cli())
  File "/home/alain/anaconda3/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/alain/anaconda3/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pdf_statement_reader/__init__.py", line 80, in pdf2csv
    df = parse_statement(input_filename, config)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pdf_statement_reader/parse.py", line 104, in parse_statement
    clean_numeric(statement, config)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pdf_statement_reader/parse.py", line 50, in clean_numeric
    df[col] = df[col].apply(format_negatives)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py", line 3458, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/alain/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc
    raise KeyError(key) from err
KeyError: 'DEBIT'

Here is my config file:

{
    "$schema": "https://raw.githubusercontent.com/marlanperumal/pdf_statement_reader/develop/pdf_statement_reader/config/psr_config.schema.json",
    "layout": {
        "default": {
            "area": [229, 51, 1041, 778],
            "columns": [97, 497, 568, 671, 778]
        },
        "first": {
            "area": [734, 51, 1117, 778],
            "columns": [97, 497, 568, 671, 778]
        }
    },
    "columns": {
        "trans_date": "DATE",
        "trans_type": "LIBELLE",
        "trans_detail": "VALEUR",
        "debit": "DEBIT",
        "credit": "CREDIT"
    },
    "order": [
        "trans_date",
        "trans_type",
        "trans_detail",
        "debit",
        "credit"
    ],
    "cleaning": {
        "numeric": ["debit", "credit"],
        "date": ["trans_date","trans_detail"],
        "date_format": "%d/%m/%Y"
    }
}

I have no balance in my bank document, so I have suppressed it.

Here is a snapshot of the bank document with the table header and two records:

image

@marlanperumal
Copy link
Owner

Is this still an issue? I've updated the project (including migrating to uv for python and package management) and fixed a couple bugs along the way. My assumption on the error you were getting before is that the headings weren't getting picked up in the targeted area. The current version should deal with that properly now.

I'm picking up this project again after a bit of a hiatus. If I don't see any response on this issue within 2 weeks, it will be closed, so that only current issues will be present and can be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants