How to compare 2 files to get only lines that are not in the second file?
<p>I have 2 files like these :</p>

<pre><code>file 1 :                     file 2 :
col1    col2                 col1     col2
john    kerry                john     kerry
adam    lord                 bob      abram  
joe     hitch               
</code></pre>

<p>I would like to compare those two files based on lastnames and firstnames to get only a file that does not contain the people in file 2, that is to say :</p>

<pre><code>desired output file :

col1     col2
adam     lord
joe      hitch
</code></pre>

<p>I tried this but I don't get the right output</p>

<pre><code>import csv

reader1=csv.reader(open('file1.csv', 'r'), delimiter='\t')
reader2=csv.reader(open('file2.csv', 'r'), delimiter='\t')
writer=csv.writer(open('desired_file.csv', 'w'), delimiter=',')

row1 = reader1.next()
row2 = reader2.next()

if (row1[0] == row2[0]) and (row1[1] == row2[1]):
    print 'equal'
else:
    writer.writerow(row1)
    writer.writerow(row2)
</code></pre>
