Extract a specific information from a text file

I have two inputs:

a- folder contains multiple text files
b- excel file
I want to develop a process that import a) and do a loop through the folder, so it could read the text files. Then extract the specific information from each text file. After it has to compare the extracted information to the excel file values b).

1 Like

Hi

Hope the below steps would help you resolve this

  1. Use a assign activity like this

arr_files = Directory.GetFiles(“your folderpath”)
Where arr_files is a variable of type array of string

  1. Now use a BUILD DATATABLE activity and create a table structure u want which can be used to compare with the excel file u have and get the output as dt-input

  2. Now use read range activity and read that excel file with datatable output named as dt

  3. Use a FOR EACH activity and pass the array variable as input and change the type argument as string

  4. Inside the loop use a READ TEXT FILE activity and pass the input filepath as item and get the output as stroutput

  5. From this string output get the information u want and add it to the datatable built earlier with ADD DATAROW activity

  6. Now you can compare the datatable read and built by ur own however u want

Have a view on this tutorial on how to use datatable

Cheers @imane.bousaad

@Palaniyappan thank you for replying, I’ll tryy what you suggest but I woonder how can I get the inormation I want from the text file??

You can use the Matches activity that requires RegEx. Using that you can select whatever information you want!

Good Automations, Cheers!

@imane.bousaad

It depends on the text and it’s format
There are n number of ways to extract the specific set of information u any

  1. Regex
  2. String manipulation methods

Choose the one which suits best to ur requirement

@imane.bousaad

ah okey Thank you

1 Like