title: python loop over unequal list row
body: <p>I have two tex files which contain unequal number of rows and columns. Now I want to compare list from one tex file with other file, and if it is match with list in other file, then print corresponding number. For e.g. my files look like</p>
  
  <pre><code>test1.txt       test2.txt
  
  XCJ2200, B      XCJ1945, A, 0.1
  XCJ2345, E      XCJ2200, B, 0.2
  XCJ2568, F      XCJ2450, C, 0.3
  ....            XCJ2590, D, 0.4
                  XCJ3000, E, 0.4
                  ....
  </code></pre>
  
  <p>So now I want to match col 1 and 2 of test1.txt with col 1 and 2 of test2.txt. So I want final output</p>
  
  <pre><code>XCJ2200  0.2
  XCJ2345  0.4
  XCJ2568
  ....
  </code></pre>
  
  <p>So far I have written following code but it is not giving answer as I want:</p>
  
  <pre><code>reader1=csv.reader(open('test1.txt','rb'))
  reader2=csv.reader(open('test2.txt','rb'))
  col1=[];col2=[];Col1=[];Col2=[];Col3=[]
  for row in reader1:
     col1.append((row[0]))
     col2.append((row[1]))
  for row in reader2:
     Col1.append((row[0]))
     Col2.append((row[1]))
     Col3.append((row[2]))
  for i in range(len(col1)):
     for j in range(len(Col1)):
       if Col1[j]==col1[i] or Col2[j]==col1[i]:
           print col1[i],Col3[j]
       else:
           print col1[i]
  </code></pre>
  
  <p>This code is printing col 1 of test1.txt in multiple times of length of col 1 of test2.txt. I know that there is something wrong in last if and else condition.</p>