title: How to filter by a column in exceljs with Javascript before transcribing results to Google Sheets API via Node
body: <p>I have written a script which uses the following:</p>
  <pre><code>// https://nodejs.org/
  // https://developers.google.com/sheets/api/quickstart/nodejs?hl=en
  // npm install googleapis@39 --save
  // https://www.npmjs.com/package/exceljs
  </code></pre>
  <p>I need to somehow map or filter results to end up with all rows in a variable which contains &quot;WN&quot; in the 11th column (which contains the region of the results or that row).</p>
  <p>The script reads a CSV sheet into a variable called &quot;data&quot; in an async function:</p>
  <pre><code>const worksheet = await wb.csv.readFile(CSVFileName, options);
        // ... use workbook or worksheet
  
      let data = worksheet.getSheetValues(); 
      data = data.map(function(r){
         return [r[1],r[2],r[4],r[11],r[13],r[15],r[16],r[54],r[56]];  
           // filter should be applied here: if r[11] = &quot;WN&quot;
  </code></pre>
  <p>I have tried to apply a filter, but I struggle working with the data as it is an &quot;array inside and array inside an array&quot; so to say:</p>
  <pre><code>let data2 = data.filter(function(region){
    if (region.data = &quot;WN&quot;) {
      return true;
    }    
  });
  </code></pre>
  <p>The code as it is doesn't filter correctly and returns the following, in stead of filtering by the 4'th item in the array.  See items other than &quot;WN&quot; in the array below:</p>
  <pre><code>[
      'AA05299040',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299041',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'P',
      data: 'WN'
    ],
    [
      'AA05299042',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299043',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299044',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299045',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299047',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299048',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299051',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299055',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299058',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299059',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299060',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299061',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299062',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'P',
      data: 'WN'
    ],
    [
      'AA05299063',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299064',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299066',
      '08/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299526',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299528',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299530',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299531',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299532',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299533',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299534',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299535',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299538',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299542',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    [
      'AA05299549',
      '09/07/2020',
      '09/07/2020',
      'KN',
      'AA',
      '41I006',
      'Inkosi Albert Luthuli Hospital',
      '09/07/2020',
      'N',
      data: 'WN'
    ],
    ... 15362 more items
  ]
  </code></pre>
  <p>I've also tried this: which gives an error:</p>
  <pre><code>let data2 = data.filter(function(region){
        if (region.data.r[4] = &quot;WN&quot;) {
          return true;
        } 
  </code></pre>
  <p>(node:16260) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'r' of undefined</p>