import csv original = open("original.csv", 'r') original = ''.join([i for i in original]) .replace("C-F", "F-C") .replace("G-F", "F-G") x = open("edited.csv", "w") x.writelines(original) x.close()