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

Return a Default Value if Field Failed to Parse #523

Open
CopperClover opened this issue Aug 21, 2023 · 1 comment
Open

Return a Default Value if Field Failed to Parse #523

CopperClover opened this issue Aug 21, 2023 · 1 comment

Comments

@CopperClover
Copy link

Is there a way to assign a default value to a specific field parser for an instance where a field fails to be be parsed? I am using a standardized template for a project and some of the fields don't exist on all of the invoices. I can obviously check this in the python code but was wondering if there was a way that I could get a defaulted value out from the templates?

At the moment I get WARNING:invoice2data.extract.invoice_template: Failed to parse field field with parser regex and the field basically doesn't exist in the returned dictionary which leads to errors down the line.

@RiekertKBW
Copy link

That's a pretty interesting Idea. I thought about something like that too, to have a standard-value, if the field can't be found.

For now, I'm doing that in the Code or with a static field if the field is mandatory.

To make a static field, you could look here:
https://github.com/invoice-x/invoice2data/blob/master/TUTORIAL.md#parser-static

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

2 participants