Using Python v2.7.4:
I have the following CSV file:
Item Number,Item Description,List Price,QTY Available
2000-000-000-380,AC - CF/M Series Green For White Hood,299.99,3
2000-000-000-400,AC - CF/M Series Orange For Black Hood,299.99,3
2000-000-000-480,AC - CF/M Series Orange For White Hood,299.99,3
I have been trying to change the file to:
Fulfillment,SKU,Qty
US,2000-000-300,3
US,2000-000-380,3
US,2000-000-400,3
So far I have the following code:
import csv
import os
inputFileName = "temp_modified.csv"
outputFileName = os.path.splitext(inputFileName)[0] + "_pro.csv"
with open(inputFileName, "rb") as inFile, open(outputFileName, "wb") as outfile:
r = csv.reader(inFile)
w = csv.writer(outfile)
r.next()
w.writerow(['Fulfillment', 'SKU', 'Qty'])
for row in r:
w.writerow((row[0], row[3]))
With this code I get the following output:
Fulfillment,SKU,Qty
2000-000-000-380,3
2000-000-000-400,3
2000-000-000-480,3
How do I insert US to the beginning column? (Just for reference there is more than just 3 rows in these csv files but for space I left out the rest.)