Write Line - Object reference not set to an instance of an object

Hi - when I am running the my workflow, for each PDF file alone, it works on only one PDF file and the other doesnt. It returns me the error below. The idea is to read the numbers from the PDF and then retrieve another number from the excel, then rename the folder with that new number retrieved from the excel. Attached is my xaml file also. Draft.xaml (11.9 KB)

Another problem is, when I put both files together in the “a_SourceFiles”, they both no longer work (although one works when it is in the folder alone.) What could be the problem?

image
image

Hello @amenoufy

Is this variable variable “results” is properly assigned?
As per the error, there is no value in the results variable.

also can you Print results.Count before to this writeline activity and check the number of items in the array.

Hi Rahul - how can I properly assign the variable results in this case? This si what I have currrently

Could it be that the OCR is not reading it well?

yes, it can be… If the results is null then you can get that error.

Can you print pdftextStr in a message box and see whether any data is there.

I am sorry but I do not know how to print pdftextStr in a message box: how can I do so?
I just tried another different file and it worked - which probably means the OCR could not read that specific file. In that case, how do I optimize the OCR to read it? I am very grateful for your help

Pass pdftextstr variable in Message Box to check if you are getting any output in pdftextstr variable.

Regards,
Saloni

pdftextStr is a string variable ryt? You can directly put that in the message box actviity.

Also what kind of file are you reading using ocr?

Im using the OCR to read PDF files that are scanned. Unfortunately it is only working on 2 files out of 10 and when I debugged, it showed that infact the OCR can not read the numbers.

1 - How can I fix that?
2 - When I run the 2 files that can be read by the OCR together, it works! But if I add one of the files that can not be read, the whole thing gives an error and the files that used to work, do not work anymore. What is the solution for this also so that it continues to work on the readable files even if there are files that can not be read?

Can you try changinb the ocr engines and check whether its working imor not

you can use If activity with condition

results.Count >1

and handle the exception.

I changed to Tesseract and it is working better than Microsoft but still not with all

is that any handwritten document and the content in the file is clear?

This is the solution for allowing the workflow to run even when there is a mistake? If so how can I add it? (Sorry I am a beginner)
How can I make the PDFs that did not work be saved in another folder - maybe named “d_Unreadable”?
Could you please show me in my worksheet
Draft.xaml (11.9 KB)

Non are handwritten. Some files the scan is not as clear as others unfortunately. Maybe is there a way to make it more readable in the settings of OCR? Also there is one example where the digits are not on the same line because there was not enough space:
So instead of 12345678-ABC
It is 12345678-
ABC

If the files are not structured, i would suggest to go with Document understanding by using the intelligent OCR package.

Normal ocr activities are having limitations to extracting the data if it’s not clear.

After downlaoding that package, should I uninstall the normal ocr package or do I need to do antyhing else before running the script?

there are some steps you need to do for document understanding. Suggesting to go through the Document understanding tutorial in the uipath academy.

If none of the ocr engines are not working then you have to go with this. Also did you tried the Uipath ocr engines also?

Yes - the tessaract was the one with the least problems! I think I shall just manually change what the OCR could not read. But for that to work, I need the workflow to work for the readable files, even when there is some files in the folder that are not readable (in that case copy those files in another folder"
How can I make the PDFs that did not work be saved in another folder - maybe named “d_Unreadable”?
Could you please show me in my worksheet. Robbot is stating using the IF fuinction but I dont know how or where.
Draft.xaml (11.9 KB)

For those files which are not working, what is the output of the ocr activity?? Is that null result??

If yes, then lineCount=InputStr.Split({Environment.NewLine}, StringSplitOptions.None).Count

If(lineCount>o)
Then, you can progress with the next step
Else use move file activity