invoice2data icon indicating copy to clipboard operation
invoice2data copied to clipboard

ValueError when using tables plugin

Open martinostvik opened this issue 5 years ago • 1 comments

Hi there, I am trying to capture two or more seperate tables from my invoices. This is an example of what they look like:

CATEGORY 1
Invoice date        Invoice number         Amount
01.03.20            HB342344           -30 000.00
03.02.20            432432             343 043.00

CATEGORY 2
Invoice date        Invoice number         Amount
01.03.20            435345              27 342.00
21.03.20            455533              -3 043.00

I first used the 'lines plug-in' and it worked just fine, the only problem is that there are several seperate tables, and I need to be able to seperate them from eachother.

I tried using the 'tables plug-in' instead as it supports multiple tables per invoice.

This is my capture field for capturing only the first table(CATEGORY 1):

tables:
   start: CATEGORY 1
   end: CATEGORY 2
   body: (?P<Invoice_Date>\d{2}\.\d{2}\.\d{2})\s+(?P<Invoice_Number>\w?\d+)\s+(?P<Invoice_Amount>-? \d{1,}\s{0,}\d{0,}\s{0,}\d{0,}\.\d{2})

when running the --debug from the console I end up getting this error: invoice2dataError

This did not happen when I used 'lines'... What is causing this error?

martinostvik avatar Mar 21 '20 11:03 martinostvik

I was missing the '-' symbol before start.

writing:

tables:
-  start: CATEGORY 1
   end: CATEGORY 2
   body: (?P<Invoice_Date>\d{2}\.\d{2}\.\d{2})\s+(?P<Invoice_Number>\w?\d+)\s+(?P<Invoice_Amount>-? \d{1,}\s{0,}\d{0,}\s{0,}\d{0,}\.\d{2})

fixed the problem! My mistake, sorry.

But it only matches on the first row. Does the tables-plugin not support several rows in each table?

martinostvik avatar Mar 21 '20 12:03 martinostvik

Your regex doesn't match the first line:

  1. Invoice_Number: \w? allows only one (optional) character. Your example is HB342344. Make that \w*
  2. Invoice_Amount: -? requires space after -. Your example is -30 000.00. Make that -?

rmilecki avatar Jan 22 '23 21:01 rmilecki