I want to use file1.csv as a lookup for file2.csv. Anything that comes up should print the entire row from file2.csv.
However, as I loop trough the rows of file2.csv and evaluate my lookup to my data I am unable to get the line variable to equal my second column (row1). What do I appear to be missing?
import csv
import sys
file1 = 'file1.csv'
file2 = 'file2.csv'
appcode = []
with open(file1, "r") as f:
f.readline() # Skip the first line
for line in f:
appcode.append(str(line.strip("\n")))
print('This is what we are looking for from file1 ...' +line)
csv_file = csv.reader(open(file2, "rb"), delimiter=",") # was rb
#loop through csv list
for row in csv_file:
print('line = '+line +' '+'row is... '+row[1])
#if current rows 2nd value is equal to input, print that row
if str(line) is str(row[1]):
print row
else:
print 'thinks '+str(line)+'='+str(row[1])+' is false'