title: D3 manipulating and filtering csv data
body: <p>I'm trying to parse a csv file to use with a line chart. The csv file is organised as follows:</p>
  
  <pre><code>----------
  
  
  Row 1 (headings): Series, Year, Economy X, Economy Y, Economy Z....
  Row 2 (value rows): Indicator 1, 2012,  38, 73.2, 28
  Row 3 (value rows): Indicator 1, 2013,  41, 74.2, 24
  Row 4 (value rows): Indicator 2, 2012,  38, 73.2, 28
  Row 5 (value rows): Indicator 2, 2013,  41, 74.2, 24
   ....
  
  ----------
  </code></pre>
  
  <p>I'm trying to create 'Economy' objects' each containing an object made up of 'Year' (coded as 'label'),  'Series' (coded as 'series'), and the corresponding value (coded as 'value').</p>
  
  <p>Following the example by 
  <a href="http://www.delimited.io/blog/2014/3/3/creating-multi-series-charts-in-d3-lines-bars-area-and-streamgraphs" rel="nofollow noreferrer">delimited.io</a> I managed to produce the objects (see 2 examples below). </p>
  
  <pre><code>[Object, Object, Object, Object, Object, Object]
  0: Object
  name: "Switzerland"
  values: Array[20]
  0: Object
  label: "2005"
  name: "Switzerland"
  series: "Indicator 1"
  value: 2.96
  __proto__: Object
  1: Object
  label: "2006"
  name: "Switzerland"
  series: "Indicator 1"
  value: 3.297018849
  </code></pre>
  
  <p>The problem is that I want to create objects only for ONE indicator in the csv file in view of plotting only the data for that indicator. I therefore need to filter out all the indicators but the one I want (for example "indicator 1"). </p>
  
  <p>The code currently reads as follows:</p>
  
  <pre><code>d3.csv("data/sample data.csv", function (error, data) {
      var whichSeries='Indicator 1';
      var xAxis = 'Year';
      var series='Series';
      var economies = d3.keys(data[0])
          .filter(function (key) { 
               return key !== xAxis &amp;&amp; key !==series});
      console.log("economies",economies);
  
      var seriesData = economies.map(function (name) {
  
        return {
          name: name,
          values: data.map(function (d) {
              return {name: name, label: d[xAxis], series: d[series], value: +d[name]};
              }
          })
        };
      });
  </code></pre>
  
  <p>How can I build seriesData only for 'Indicator 1'?</p>
  
  <p>Thanks a lot!!</p>
  
  <p>Terry </p>