I am having trouble with an OCR activity. I am using OCR to extract 8 values from a PDF. I am having trouble renaming the PDF file using 2 of the 8 values. For example I have a PDF file named “Sample 123”, I use OMNIOCR to read the PDF file, I save 8 field to an excel workbook. I then need to take two of the values extracted being “Customer” and “Date” and add these to the end of the PDF file name " SAMPLE 123 Customer Date".
I do not know how to assign Customer and Date as variables from the OCR extraction to add to my move file activity to handle the renaming of the file.
@MF.RPA … read the excel file and save it to datatable. Do a for each for each files and inside that do another for each row for datable and use move file activity for renaming.
For extracting the value from excel use Row(“CustomerName”).tostring and similarly for date.
If you could share the screenshot of the Excel and Filenames in the folder…it would be easy to provide much more better help…
Hi, thank you for the quick reply. I suppose your solution would work, I was wondering if I could just assign the values expressed in the taxonomy as variables. I will give your idea a try and report back with my results.
I am not able to share a screenshot unfortunately. The excel file name is Results and a sample file name is “Sample 123”, keep in mind I have 100’s of files with unique names.
@MF.RPA …Now I got an idea on what you are asking for…Here you go…If you see the below screenshot, I have extracted the InsuredID which is one of the taxonomy fields from the extractedDataset…
In my case I built StrOutputSheet = “OutputData_” +ExtractionDataset.Tables.Item(“Simple Fields”).Rows(0).Item(“Insured ID”).ToString + “_” +Datetime.Now.ToString(“MM_dd_yy”) + “.xlsx”
So when Processing the file itself, creating a unique file names using the taxonomy fields as shown below.
Thank you for both suggestions. I was hoping to use your second suggestion but I am having some issues with it. Could you share the code to the right of your first assign activity? I am getting an error there.
Below I have included a few screenshots of my work as it stands now. After the data extraction is complete, I create a data table. Is this where I should begin the assign activity? I then use an if statement to append each record to an excel file. As a separate question, would it be easier to read the data in the append data area and create a Customer variable and then add a move file activity?
I was thinking that something like this might work but now I receive an error when moving the file. The error states that the file cannot be moved because the file already exists. The file does not exist, so I am not sure why I am getting this error all of a sudden…
@MF.RPA – I see the problem here…After you save the first StrCustomerNo and StrPO…that value will be used for all the Files until it finish processing all the files…So this idea will/might not work I think.
It did not work. The application did not rename or move the files but it also did not fail. Would you be able to share the code to the right of your first assign activity? I tried your recommendation but I was receiving an error.
Sorry, I missed your last reply clarifying the assign activity issue. I see that you are writing the data to an excel file. I am not understanding how the code below actually renames the file. I am sorry.
@MF.RPA …It does not rename the file , my idea is to create a file with Invoice no/Customer ID and with the date - first time itself. So that i dont have to rename after it created.
Are we on the same page? sorry, i guess I might have misunderstood your requirement…
But idea is, You can extract any value from the extracted dataset and use it for your file naming. That’s what I have showed above.
Thank you for the advice, I think I have spent too much time at the keyboard today. I am getting an error that my assign activity is not set to an instance of an object. I might have to pick back up tomorrow.
Hi @MF.RPA …Sure…Yes please…But unfortunately I can’t share the full xaml I will try to help as much I can. I think if you look close you can able to do it.
Below you will find my example, perhaps you can spot the error? When I run the script I am receiving the following error “Reference not set to an instance of an object”
Hi @MF.RPA …I have spotted where you missed…When you create an output from the extractedResults, all your taxonomy fields will be created under Simple fields sheet as shown below…
I am trying to take the Customer name variable and assign it to the end of the existing PDF file name and move the file to another location.
StrPathFrom is the folder where the PDF originated. StrPathTo is the location where the file is being moved to. After adding the .pdf file extension, I no longer have an error. The files do not rename and do not move to the StrPathTo location.
Paths to and from do not have file names, just file locations.