Reputation: 19
I have one .csv
file.
I want to convert the value of a particular column in my data set to upper case.
The values are 'Y'
and 'N'
and 'y'
.
I want to convert 'y'
to uppercase 'Y'
. Please help.
Upvotes: 1
Views: 900
Reputation: 1423
You could start with something will this:
import csv
inFile = open('input.csv')
outFile = open('output.csv', 'w', newline='')
inReader = csv.reader(inFile)
outWriter = csv.writer(outFile)
for row in inReader:
row[1]=row[1].upper()
outWriter.writerow(row)
Using an input file, 'input.csv' like this:
first, second, third, fourth, fifth, sixth
a, b, c, d, e, f
g, h, i, j, k, l
You should get an output file, 'output.csv', like this:
first, SECOND, third, fourth, fifth, sixth
a, B, c, d, e, f
g, H, i, j, k, l
If you don't, let me know.
Upvotes: 1