How to get the contents and the line number inside of the text file?

Hello I’m new here,

How to get the line number and its contents inside of the file?

For example:
I have a file named BeforeExample and it has a subfolder named filter, inside of the subfolder it has a .config file named filteredMessages.cfg where this are the contents inside of the .config file:

#test1
##########################
#build:apps
3AP15
#AR1

Note: All I have to get is the content named “#test1” also print the line number where to find the #test1.

Sample output:

filteredMessages.cfg
before_change(line:1) : #test1
after_change :

Hello @fniedez you can convert it to the list and you will get line number by adding +1 to that you will get the same

Hello @Swaroop_Singh_R

I’m new here, sorry, I can’t follow your example also I faced a lot of problems. Can you please do some example?

Thanks,
France

Dear @fniedez Please share one template text file so I will try send the sequence file

Hello @Swaroop_Singh_R

Please, kindly check your inbox I already sent a message to you.

Here’s all the example sequence that you need:
BeforeExample.zip (1.2 KB)
AfterExample.zip (1.3 KB)

Thanks.
France

Hello @fniedez please check below partial template please check

dummy.xaml (8.0 KB)

1 Like

Hello @Swaroop_Singh_R

Okay let me check it first then if I have some problems, I’ll raise it immediately.

Thanks,
France

1 Like

Hello @Swaroop_Singh_R

I already check your example, it’s quite good but, in this part image instead of printing the literal FileName, get the exact FileName into directory and the output will be the same as “filteredMessages.cfg”.

Thanks,
France

Hello @fniedez yes sir we can the same by below mentioned method

Path.getfilname(“filepath”)

@Swaroop_Singh_R

It prints out the whole path, I just need to get and print the FileName like this “filter_message.cfg” but do not declare it as literal string.

Thanks,
France