how to replace a word in csv file using python

Solutions on MaxInterview for how to replace a word in csv file using python by the best coders in the world

showing results for - "how to replace a word in csv file using python"
Elena
03 Sep 2020
1import csv
2
3inputfile = csv.reader(open('civil-war-battles.csv','r'))
4outputfile = open('placelist.txt','w')
5
6i=0
7
8for row in inputfile:
9    place = row[2].replace(' ,',',')
10    print place
11    outputfile.write(place+'\n')
12    i+=1