import csv
import sys
source = csv.DictReader(open('source.csv'))
export = csv.DictReader(open('export.csv'))
sys.stdout = open('output.csv','w')
val = 0
def output():
for row in source:
val = row['SKU']
for row in export:
if row['SKU'] == val:
print '"' + row['SKU'] + '"' + ',' + '"' + row['DESC'] + '"' + ',' + '"' + row['COST'] + '"' + ',' + '"' + row['MSRP'] + '"' + ',' + '"' + row['CORE'] + '"' + ',' + '"' + row['WEIGHT'] + '"' + ',' + '"' + row['HEIGHT'] + '"' + ',' + '"' + row['LENGTH'] + '"' + ',' + '"' + row['WIDTH'] + '"'
else:
continue
output()
This grabs just the first SKU in the source file. And not for all 15000 skus in the source file. Formatting is correct. Since this is built on a code that functions for filtering using information from the export file only, (no source csv) I fell like my problem is within the second for loop, I'm not well versed enough to troubleshoot it though.