Text file automation


This is an text file.

  1. I want to count only those 11 lines which are starting with numbers.
  2. Than i want to check in a particular folder that if it contains 11 text files.
  3. Can i read only those values which are mentioned after numbers(Like: AAAAAA, BBBBBB)

try this regex in Matches activity. You can tweak it to make it suit better for your needs.

^\s*\d+\s*([A-Z]+)\s.*$

image

2 Likes

Hi @Rahul_Tomar1

Use the activity Matches. You can keep the below setup:

Regex Pattern = \s(\d+)\s(\w+)

Use For Each activity:

Keep the below setup, Groups(1) will hold the numbers, Groups(2) will hold AAAA, BBBB etc.

image

Thanks @kunalhore2891
Now suppose in group 2 there are 7 words like AAAAAA,BBBBBB… And
In an folder we have 15 text files. From which 7 different text files have these 7 words written.
Can we search each word like AAAAAA in every text file and fild out which file have this word.

Without using for each, can we assign group2

@Rahul_Tomar1 - Regexvar(0).groups(2).tostring…

For Reference…

U can read an entire text file using Read Text File activity. It will store the data of the text file into a string variable. Let us assume the name of the variable is TextFileString

To see if a keyword exist in this text file you can use::
TextFileString.Contains( keyword )

If it returns True then the file has that keyword.