title: Loop within loop when comparing csv files in Python
body: <p>I have two csv files. I am trying to look up a value the first column in one file (file 1) in the first column in the other file (file 2). If they match then print the row from file 2.</p>
  
  <p>Pseudo code:</p>
  
  <pre><code>read file1.csv
  read file2.csv
  loop through file1
  compare each row with each row of file 2 in turn
      if file1[0] == file2[0]:
          print row of file 2
  </code></pre>
  
  <p>file1:</p>
  
  <pre><code>45,John
  46,Fred
  47,Bill
  </code></pre>
  
  <p>File2:</p>
  
  <pre><code>46,Roger
  48,Pete
  49,Bob
  </code></pre>
  
  <p>I want it to print :
  <code>46 Roger</code></p>
  
  <p>EDIT - these are examples, the actual file is much bigger (5,000 rows, 7 columns) 
  I have the following:</p>
  
  <pre><code>import csv
  with open('csvfile1.csv', 'rt') as csvfile1, open('csvfile2.csv', 'rt') as     csvfile2:
      csv1reader = csv.reader(csvfile1)
      csv2reader = csv.reader(csvfile2)
      for rowcsv1 in csv1reader:
          for rowcsv2 in csv2reader:
              if rowcsv1[0] == rowcsv2[0]:
                  print(rowcsv1)
  </code></pre>
  
  <p>However I am getting no output. </p>
  
  <p>I am aware there are other ways of doing it (with dict, pandas) but I cam keen to know why <em>my</em> approach is not working.</p>
  
  <p>EDIT: I now see that it is only iterating through the first row of file 1 and then closing, but I am unclear how to stop it closing (I also understand that this is not the best way to do do it).</p>