I am having trouble using the table plug-in. Please help
Hey, so i am attempting to write a little python program that can automate a tedioustask at work for me. I am using Invoice2data to do this, however i can't seem to figure out how to use the table feature. Het is a clip out of the invoice that i need and a code snippet of how i am attempting to solve it. Here is the code snippet: table:
- start: 'Art.nr.\s+Beskrivelse\s+Antal\s+Enhed\s+Enhedspris\s+Moms\s+%\s+I alt ekskl. moms'
end: 'Moms %\s+Momspligtigt'
body: '(?P
[\d+]+)\s+(?P [\S+.\S+.\S+.\S+]+)\s+(?P [\d+.]+)\s+(?P [\d+.]+)\s+(?P [\d+.]+)\s+(?P<i_alt_eks_moms>[\d+.]+)'
And the screen dump is attached
Thanks for your interest in invoice2data.
Kinda hard to help without the full input. But it looks like your confusing the syntax.
From the screenshot you attached. You can use as start the 'Art.nr.\s' Then try move the complete regex that you have written to the table section.
( Heheh I'm writing this from my phone, don't know the complete syntax out of my head . But this should give you an pointer to solve your regex. )
For this part of the content, you can also use the line parser.. Maybe that's a bit more easy.
Hey Bosd thanks for your answer quick, i am still confused tho. Where is the 'table section'? Is it something i have to include or do you mean the body? I have tried using the line feature also with out luck...
@LilMouses Based in the image you provide, I see 2 jobs there.
Job 1 for the Line parser. Marked in blue Job 2 for the Table parser Marked in Green..
lines:
start: Art[.]nr
end: \s+Moms\s[%]\s+Momspligtigt
line: (?P<code>\d+)\s+(?P<name>(\S+(?:\s\S+)*))\s(?P<qty>\d+[,.]\d+)\s+(?P<uom>\w+)\s+(?P<price_unit>\d*[.,]?\d+[,.]\d{2})\s+(?P<line_tax_percent>\d+)\s+
types:
qty: float
price_unit: float
Then the green part to be used with the table parser will look something like this.
tables:
- start: \s+Moms\s[%]\s+Momspligtigt
end: '\Z'
body: (?P<line_tax_percent>\d+[,.]\d+)[%]\s+(?P<I_dont_know_what_this_is>.*)\s+(?P<line_tax_amount>\d*[.,]?\d+[,.]\d+)\s+
You may need to fine tune the regexes here. As the masked part is not included. I quickly copied and pasted some regexes from one of the exsisting templates. What I put in here is is untested from my side. But it will point you into the right direction.
For better debugging, you could generate some demo with forged info in text format. So we could test it in regex101.com or directly with the plugin.
On second thought..
The green circled area looks like it is a tax table.
In that case it case it can also be parsed with the line parser. Following the tax_lines format.
For en example see here
Thank you very much bosd