Looping through Files in a folder and getting text from file

Hi
I am downloading multiple files from a FTP folder with a Precise pattern of File name , All files are .txt and need to grab some data inside of file and processing with more activities , i want to know how i can extract the date part from this format

ARR_SI_MedicalTranscriptionBillCorp_PD_20200731_03291.TXT

and Inside the file on line 3 i have this format of data

03,3303003291,USD,010,43600,015,44800,/

I want to extract 3303003291 and to utilize in Further activities

Thanks

Hi @adeelaslam

By using Regex u can extract date from the file name as below :-

image

Note :- If within file name, only date count should be of 8 digit all the time

Another way is by string manipulation :-

String str = β€œARR_SI_MedicalTranscriptionBillCorp_PD_20200731_03291”
Int count = str.Length-str.Replace("","").Length
String date = str.Split("
"c)(count-1)

Output :-
image

By using Regex u can extract 3303003291 from inside the file as below :-

image

Note :- If within file data, only that digit count should be of 10 digit all the time

Another way is by string manipulation :-

String str = β€œ03,3303003291,USD,010,43600,015,44800,/”
Int count = str.Length-str.Replace(",","").Length
String date = str.Split(","c)(count-6)

Output :-
image

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

2 Likes

Hi Paratik

Thanks for the Update !

I am unable to find the Regular Expression Activity , can you please help how to use Regular Expression or Use above code to get File name , also inside the file can i Fix the Line Number to get Account Number.

@adeelaslam

Use Matches Activity and give the input and create output variable

Hope this helps

Thanks

Hi
I have used Match Activity for FileName String like \d{8} but i am getting this on output

System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]

Hi @adeelaslam

Below is the thread which will give you overview for how to use Matches Activity which is used for applying regular Expressions :-

And Inside the file if you have to fix Line Number then 1st of all i should have a look around that what all Data/1st Two lines consist of and what pattern they follow

So for that u have to provide me the input Data within the file for the same

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer: