Aug-29-2018, 05:57 PM
Hello all, I think I need a lot of help.
I have a file named CONFIG.inp. What I need to do is to create 100 others (i.e. CONFIG1, CONFIG2, etc) replacing just one thing in CONFIG.inp.
One of my problems is: in the replace method I would like to replace 'a' with b, c, d or e one in each file but of course, it will be replaced with 'names'.
And the other problem is: how could I create the CONFIG1, CONFIG1, CONFIG3 and CONFIG4 output files?. I only manage to do it just for one file.
Thank you very much.
clara
I show you what I think I should do (only with 4):
I have a file named CONFIG.inp. What I need to do is to create 100 others (i.e. CONFIG1, CONFIG2, etc) replacing just one thing in CONFIG.inp.
One of my problems is: in the replace method I would like to replace 'a' with b, c, d or e one in each file but of course, it will be replaced with 'names'.
And the other problem is: how could I create the CONFIG1, CONFIG1, CONFIG3 and CONFIG4 output files?. I only manage to do it just for one file.
Thank you very much.
clara
I show you what I think I should do (only with 4):
a=['b','c','d','e'] for names in a: s=open('CONFIG.inp').read() s=s.replace('a','names') f=open('CONFIG.inp','w') f.write(s) f.close()