title: Replace multiple fields/columns in one files with contents from another file if the headers are the same
body: <p>I have two CSV files that share similar headers:<code>sample_scv_1.csv</code> is::</p>
  
  <pre><code>Transaction_date,Name,Payment_Type,Product
  1/2/09 6:17,NA,Mastercard,NA
  1/2/09 4:53,NA,Visa,NA
  1/2/09 13:08,Nick,Mastercard,NA
  1/3/09 14:44,Larry,Visa,Goods
  1/4/09 12:56,Tina,Visa,Services
  1/4/09 13:19,Harry,Visa,Goods
  </code></pre>
  
  <p>Similarly, <code>sample_scv_2.csv</code> is ::</p>
  
  <pre><code>Transaction_date,Product,Name
  1/2/09 6:17,Goods,Janis
  1/2/09 4:53,Services,Nicola
  1/2/09 13:08,Materials,Asuman
  </code></pre>
  
  <p>Here in these two files Columns/Fields <code>Transaction_date</code>, <code>Product</code>, <code>Name</code> are common and I want to replace fields <code>Product</code>, <code>Name</code>  in <code>sample_scv_1.csv</code> iff the transaction date matches in both the files.</p>
  
  <p>This is a toy example and my file is big. For this example I can separate the cases where columns are equal and use indices to replace using  csvtool as:</p>
  
  <pre><code>head -4 sample_scv_1.csv &gt; temp1.csv
  tail -3 sample_scv_1.csv &gt; temp1_1.csv
  #sudo apt-get install csvtool
  csvtool pastecol 2,4 3,2 temp1.csv sample_scv_2.csv &gt; temp1_2.txt
  cat temp1_2.txt temp1_1.csv &gt; sample_scv_1.csv
  </code></pre>
  
  <p>My required output is ::</p>
  
  <pre><code>Transaction_date,Name,Payment_Type,Product
  1/2/09 6:17,Janis,Mastercard,Goods
  1/2/09 4:53,Nicola,Visa,Services
  1/2/09 13:08,Asuman,Mastercard,Materials
  1/3/09 14:44,Larry,Visa,Goods
  1/4/09 12:56,Tina,Visa,Services
  1/4/09 13:19,Harry,Visa,Goods
  </code></pre>
  
  <p>I can determine until which line the transaction date matches but I can not know the indexes where the two columns overlap: like Name and Product in first file. One issue is easy as all columns of <code>sample_scv_2.csv</code> will be in <code>sample_scv_1.csv</code>. Any ways to do this efficiently.</p>