title: Python merging two CSV by common column
body: <p>I am trying to merge two csv files with a common column and write it to a new file. For example
  product.csv table will have columns </p>
  
  <pre><code>      product_id     name        
         1           Handwash      
         2           Soap          
  </code></pre>
  
  <p>and subproduct.csv will have columns </p>
  
  <pre><code>      product_id subproduct_name volume
         1           Dettol         20
         1           Lifebuoy      50
         2           Lux           100
  </code></pre>
  
  <p>The output sales.csv file should be like:</p>
  
  <pre><code>  product_id        name      subproduct_name     volume 
         1           Handwash      Dettol            20   
         1           Handwash      Lifebuoy          50
         2           Soap           Lux             100 
  </code></pre>
  
  <p>I have tried to create two dictionaries:</p>
  
  <pre><code>with open('product.csv', 'r') as f:
  r = csv.reader(f)
  
  dict1 = {row[0]: row[1:] for row in r}
  
  with open('subproduct.csv', 'r') as f:
  r = csv.reader(f)
  
  dict2 = {row[0]: row[1:] for row in r}
  </code></pre>