Reading csv file and compare objects to a list
<p>I have a .txt file,primary list, with strings like this:</p>

<pre><code>f
r
y
h
g
j
</code></pre>

<p>and I have a .csv file,recipes list, with rows like this:</p>

<pre><code>d,g,r,e,w,s
j,f,o,b,x,q,h
y,n,b,w,q,j
</code></pre>

<p>My programe is going throw each row and counts number of objects which belongs to primary list, for example in this case outcome is:
2
3
2
I always get 0, the mistake must be silly, but I can't figure it out:</p>

<pre><code>from __future__ import print_function
import csv

primary_data =  open('test_list.txt','r') 
primary_list = [] 
for line in primary_data.readlines():
    line.strip('\n')
    primary_list.append(line)

recipes_reader = csv.reader(open('test.csv','r'), delimiter =',')

for row in recipes_reader:
    primary_count = 0
    for i in row:
        if i in primary_list:
            primary_count += 1
    print (primary_count)
</code></pre>
