I wrote a script as like below
arr = [(line.rstrip('\n').split(';')) for line in open('C:/Config_Changer.csv')] import sys import fileinput for i, line in enumerate(fileinput.input('C:/1.cfg', inplace = 1)): for f,t in arr: if 'description' not in line: line = line.replace(f, t) sys.stdout.write(line)
ok my problem is my config changer file is like
when I run the script it first change 1/1/1 to 1/1/2 then to 1/1/4 but I don't want that; I want that it changes 1/1/1 to 1/1/2 and 1/1/2 to 1/1/4 so when its replacing the values from array;I want that it should read from the first buffered file not the last changed file :) How can I do that ?
Thank you very much for all your help in advance
Edited 4 Years Ago by pyTony: Phyton -> Python in title