I have the following CSV file.
Item Number,Item Description,List Price,QTY Available
3079-000-006-000,Covert GTX Liner Size 6,99.99,8
3079-000-007-000,Covert GTX Liner Size 7,99.99,36
3079-000-008-000,Covert GTX Liner Size 8,99.99,181
I need to limit the QTY Available to 10. So If row[3] is greater than 10 I want the value 10 to show up in that role. So far I have:
import csv
import os
inputFileName = "temp.csv"
outputFileName = os.path.splitext(inputFileName)[0] + "_modified.csv"
with open(inputFileName, "rb") as inFile, open(outputFileName, "wb") as outfile:
r = csv.reader(inFile)
w = csv.writer(outfile)
r.next()
w.writerow(['Item Number', 'Item Description', 'List Price', 'QTY Available'])
for row in r:
if row[3] >= 10:
row[3] = 10
w.writerow(row)
This turns all the values in the QTY Available column to 10 however I only want to change the ones that exceed 10. How can I limit the values to 10?