I am working on one task on Automation which are as below
- Read all text file from folder in Loop - completed
- dynamically extract data from each file based on few keyword stored in Array - Facing Challenges
- and load in extracted value in Table/Excel - am aware of this process
Currently facing challenges on Task 2
I have array of 5 element code “A123” “B234” “C345” “D567” “E098” .This would present anywhere in “Text file” which am reading in task 1.
Q1) looking for solution -Read all lines for text file in loop
With read text - i am able to get Text file content
But not able to read all lines - in loop till last line.
Here i need some direction on, how to use File.readalllines or any other method to read all lines of text files.
Q2) and dynamically, how to scan each lines with each of Code of Array and once its found , with its start position will be getting next 15 length word after that which is my ultimate GOAL.
I would be able to last part of extract, once am able to solve able to problems
StartIndex = item.ToString.IndexOf(policyPrefix,0)+policyPrefix.Length
Output = = item.ToString.Substring(startIndex-4,14)