All -
I am attempting to read a single row from a csv file and then have it search another csv file.
I have a masterlist.csv that has a single column called empID. It contains thousands of rows of 9 digit numbers. As well I have ids.csv that also contains a single column called number. It contains hundreds of rows. I am attempting to pull a row from the ids.csv do a search on the masterlist.csv and print out whether it has been found. Then it needs to move to the next row in ids.csv until each row in ids.csv has been searched within the masterlist.csv. I thought it would be as simple as this, however it is not throwing any errors nor returning any results.
Using Python 2.7.12 import csv
masterReader = csv.reader(open("masterlist.csv", "rt"), delimiter=",")
idsReader = csv.reader(open("ids.csv", "rt"), delimiter=",")
for number in idsReader:
for empID in masterReader:
if number == empID:
print (" Found in MasterFile")
else:
print ("Is Not Found in MasterFile")
Edit: Adding snippet of data used for testing.


.strip()may solve the issue. Also, you can have it printnumberandempIDto ensure you're getting what you think you're getting.