How to fuzzy search a text file and return the relevant line?

Hi!

First time posting - I have searched high and low, used examples from other posts and even tried regex to no avail. I’m looking for some advice or set of fresh eyes, please. My use case is:

  • 1000’s of pdf files (invoices) are stored in a share drive with the file naming convention of: vendor name inv#(s) date
  • I have a report from my accounting system that lists similar information as the file name
  • I would like to be able to read the report, take the vendor name & invoice# from the accounting report and copy the pdf file to another folder.

A user currently goes to explorer and does a manual search for each invoice.

What I have tried so far in UiPath:
Step 1. Created a text file, listing the folder contents

  • created a string array to directory.getfiles
  • loop through results and write the filepath+filename to a text file for all files in the share drive

Step 2. Read text file, perform search and return the relevant line where vendor & inv match

  • performed read text file created in step 1 (tested and can see the contents of the output string)
  • for the search i have tried numerous approaches but cannot work out how to perform the search based on partial information and then return the entire line.

Combined images due to new user limitation!

Thanks for any help or pointers.

1 Like

You could loop through the array of filenames you created with the directory.getfiles (don’t forget to set the typeargument to string in the properties) and use an IF statement with xxx.contains(“vendor name”)=True as condition. You can of course add more conditions with AND/OR.
The item will contain the full name

image

Hey!
Could you give me a little more info on the script you have used here?

What happens if word is featured more than once? Would it return a list/array?

Thanks