First of all I have to say that I am not very experienced in Python programming. I did a lot of data analysis and programming with R for several years. But now I move to Python especially for handling of textfiles.
For what I need your help:
I have a first textfile like to following
My name is Ben.
I am 50 years old.
In a second textfile I have a table with different names and different numbers
Tom, 20
Tim, 30
Tina, 40
I need a loop in which the name 'Ben' is replaced with 'Tom' in the first iteration, 'Tim' in the second and 'Tina' in the last as well as the age of 50 is replaced with 20, 30 and 40. The three new files should be exported as textfile.
In R I would call a search and replace function in a for loop with the rownumber as counter.
In reality my textfile is much more complicated like the little example. Therefore, I am not able to do the seach and replace within R and I want to use Python.
I am able to do the search and replace in Python as well. But I need a hint how I can run such a search and replace in a loop.
Any help is highly welcome.