title: Add rows from CSV with duplicate values in javascript
body: <p>Using Papaparse, I am trying to add together rows with a duplicate SKU.  I am trying to do this without adding another JS library like D3.
  My CSV looks like this:</p>
  <pre><code>SKU,Daily total,Weekly total
  AAA111,2,10
  BBB222,4,6
  CCC333,11,19
  AAA111,5,11
  BBB222,6,12
  </code></pre>
  <p>I have it output all the rows from the table, but I need to dynamically add all the rows with the same SKU number together.</p>
  
  <pre><code>    &lt;script&gt;
          function datasetToMap(data) {
          var ret = {};
          $(data).each(function(index, row) {
              ret[row] = row;
          });
             
      return ret;
  }
  
  function appendMapToTable(map) {
      var $table = $('#my-table');
      Object.keys(map).forEach(function(key, i) {
          var rowData = map[key];
            var row = $('&lt;tr class=&quot;rownum-' + [i] + '&quot;&gt;&lt;/tr&gt;');
        $(rowData).each(function (j, cellData) {
          row.append($('&lt;td class=&quot;' + [j] + '&quot;&gt;'+ cellData +'&lt;/td&gt;'));
      });
        $table.append(row);
    });
  }
  
  $.ajax({
      type: &quot;GET&quot;,
      url: &quot;https://cdn.shopify.com/s/files/1/0453/8489/t/26/assets/testcsv.csv&quot;,
      success: function (data) {
          appendMapToTable(datasetToMap(Papa.parse(data).data));
      }
  });
  </code></pre>
  <p>I am trying to get AAA1111 to have a count of 7 and 21, and BBB222 to have a count of 10 and 18 in the table.</p>
  <p>I have a working example here: <a href="https://codepen.io/BIGREDBOOTS/pen/LjmojW" rel="nofollow noreferrer">https://codepen.io/BIGREDBOOTS/pen/LjmojW</a></p>