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

Don't set empty fields in output #456

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

rmilecki
Copy link
Collaborator

Before introducing parsers concept extract() did not set empty fields in
output. So in case of re.findall() returning an empty list there was a
warning like:
WARNING:invoice2data.extract.invoice_template:regexp for field <foo> didn't match
and on <foo> in output dictionary / file.

That has unintentionally changed after commit 670f8729b7b6 ("Extend
fields syntax to support associative arrays & add 2 initial parsers
(#308)"). Output can now look like:
[
    {
        "issuer": "Company",
        "amount": 12.34,
        "date": "2023-01-01",
        "invoice_number": "01/2023",
        "test_field": [],
        "currency": "EUR",
        "desc": "Invoice from Company"
    }
]

Bring back old behaviour and don't set empty fields:
[
    {
        "issuer": "Company",
        "amount": 12.34,
        "date": "2023-01-01",
        "invoice_number": "01/2023",
        "currency": "EUR",
        "desc": "Invoice from Company"
    }
]

Before introducing parsers concept extract() did not set empty fields in
output. So in case of re.findall() returning an empty list there was a
warning like:
WARNING:invoice2data.extract.invoice_template:regexp for field <foo> didn't match
and on <foo> in output dictionary / file.

That has unintentionally changed after commit 670f872 ("Extend
fields syntax to support associative arrays & add 2 initial parsers
(invoice-x#308)"). Output can now look like:
[
    {
        "issuer": "Company",
        "amount": 12.34,
        "date": "2023-01-01",
        "invoice_number": "01/2023",
        "test_field": [],
        "currency": "EUR",
        "desc": "Invoice from Company"
    }
]

Bring back old behaviour and don't set empty fields:
[
    {
        "issuer": "Company",
        "amount": 12.34,
        "date": "2023-01-01",
        "invoice_number": "01/2023",
        "currency": "EUR",
        "desc": "Invoice from Company"
    }
]
@rmilecki
Copy link
Collaborator Author

I've just noticed that my old #308 changed parsing behaviour.

I'm wondering if the old behaviour made more sense and should be brought back. Any opinion on this?

@rmilecki rmilecki requested review from bosd and m3nu January 28, 2023 12:47
@bosd
Copy link
Collaborator

bosd commented Jan 29, 2023

I am kinda neutral on this. Both methods has his up and downsides.
But I tend to lean towards returning to the old behavior.

Copy link
Collaborator

@bosd bosd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's restore the old behavior. :+1

@rmilecki rmilecki merged commit bc667cf into invoice-x:master Feb 1, 2023
@rmilecki rmilecki deleted the dont-set-empty-fields branch February 1, 2023 21:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants