Python - Searching .csv file with rows from a different .csv file
<p>All -</p>

<p>I am attempting to read a single row from a csv file and then have it search another csv file.</p>

<p>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.</p>

<p>Using Python 2.7.12
    import csv</p>

<pre><code>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")
</code></pre>

<p>Edit: Adding snippet of data used for testing.</p>

<p><a href="http://i.stack.imgur.com/vJroB.png" rel="nofollow"><img src="http://i.stack.imgur.com/vJroB.png" alt="enter image description here"></a></p>

<p><a href="http://i.stack.imgur.com/nYhe4.png" rel="nofollow"><img src="http://i.stack.imgur.com/nYhe4.png" alt="enter image description here"></a></p>

<p>You could easily find the numbers that are common to both by using the <em>intersection of sets</em> and the <code>csv.DictReader</code> as your reader object (not sure if the file actually contains a single column):</p>

<pre><code>with open("masterlist.csv") as f1, open("ids.csv") as f2:
    masterReader = csv.DictReader(f1)
    idsReader = csv.DictReader(f2)

    common = set(row['empID'] for row in masterReader) \
           &amp; set(row['number'] for row in idsReader)
    print(common)
</code></pre>

<hr>

<p>Or use a check of list membership to find rows in <code>idsReader</code> that are contained in <code>masterReader</code>:</p>

<pre><code>masterReader = [row['empID'] for row in masterReader]

for row in idsReader:
    if row['number'] in masterReader:
        print (" Found in MasterFile")
    else:
        print ("Is Not Found in MasterFile")
</code></pre>

<p><em>P.S. considering the update to your question, you may not even need the csv module to do this</em></p>

python csv