OCR loop function


I would like to know if there is a functionality to loop an OCR function in RPA Express. My process goes like this:

I have an invoice, with the usual details like invoice number, invoice date, due date, vendor name, etc. I have no problem doing OCR with that.
Then comes the item list. Per item, there is the quantity, description, currency, and amount. Per line item, I have to get these four pieces of information and store them in a variable.

My question is:
Is there a functionality in RPA Express with a loop that can read the first line item, store the data in variables, and if the variable is not empty, capture the next line item, and repeat the process? And if the variable becomes empty, finish the process, and move to the next action?

Appreciate your help on this!

Hi @airahdelafuente, do I understand correctly that you can have different number of lines in different invoices, you don’t know in advance how many rows there will be, and you need to save the data for each line?

Hi @ashapkina, thank you for the response.

Yes that’s right. 1 line item, save the data to variables, input those variables to a database, move to the next line item, save to previous variables, repeat.

Also, does OCR really throw an error if the capture region is a blank space? Thanks

I think you can build your bot like this:

  • read the required data fields in the 1st line
  • add an OCR action to read if there is anything in the second line, put the result in variable “x”, for example.
  • use condition: If x is not empty, add OCR actions for the second line, Else - nothing
  • repeat it for all lines.

It is not a scalable solution, but you cannot use OCR in a loop as the capture region will be in a different position for each line.

Yes, it is a bug we currently have. Thanks for reporting it.
We will try to fix it for one of the nearest releases.


I have tried this, but I get an error since the OCR will read the last line and it’s blank.

Are your invoices in image or PDF format?

If it is PDF, it can be possible to open it in Firefox and use Xpaths to extract data as suggested by @wilbertyYuUdrW in this post Working with PDF using Xpath as substitute for OCR

Hi @ashapkina, thank you. I will try this.

1 Like

If image means any solution?

@gdharmarajan if they are in image format, you cannot use Xpaths with them, only OCR.

1 Like