title: How to join two CSV files in python on a common column
body: <p>I have file1.csv containing following fields :</p>
  
  <pre><code>Name,EmailId,City
  Roger,roger@gmail.com,pune
  </code></pre>
  
  <p>Second file file2.csv contains following fields:</p>
  
  <pre><code>City,State
  Pune,Maharashtra
  Mumbai,Maharashtra
  </code></pre>
  
  <p>So I want a output file containing :</p>
  
  <pre><code>Roger,roger@gmail.com,Pune,Maharashtra
  </code></pre>
  
  <p>How should I do it?
  I have written the code below.</p>
  
  <pre><code>def getStateof():
      reader1 = csv.reader(open(r'C:\Users\admin\Desktop\compare\allUsers1.csv', 'r'), delimiter=',')
      reader2 = csv.reader(open(r'C:\Users\admin\Desktop\compare\mahrashtra.csv', 'r'), delimiter=',')
      for row1 in reader1: 
          for row2 in reader2:
              if(row1[5]==row2[1]):
                  print(row1)
  getStateof()   
  </code></pre>