title: How to parse Xlsx file and search columns by NLP JSON dictionary
body: <p>I'm working on a kind of magical xlsx parsing where I need to parse a complex xlsx file (it contains some presentational and useless informations as a header, and a data table).</p>
  <p>What I'm trying to do is parsing the file (that's cool), and I'm trying to figure out where the table starts. For that what I want to do, is having a kind on dictionary as JSON.</p>
  <p>Since the xlsx's files are dynamics and are all supposed to be some product ordering topics, I want to find the table's header row by &quot;blindly&quot; looking for column names according to the JSON dictionary below.</p>
  <pre><code>{
      &quot;productName&quot;: [
          &quot;description&quot;,
          &quot;product&quot;,
          &quot;name&quot;,
          &quot;product name&quot;
      ],
      &quot;unit&quot;: [
          &quot;unit&quot;,
          &quot;bundle&quot;,
          &quot;package&quot;,
          &quot;packaging&quot;,
          &quot;pack&quot;
      ]
  }
  </code></pre>
  <p>Here for example, we suppose one column header is going to be &quot;bundle&quot;, and another &quot;description&quot;. Thanks to my json, I'm suppose to be able to find the key &quot;productName&quot; and &quot;unit&quot;. It's a kind of synonym searching actually.</p>
  <p>Questions are :</p>
  <p>1/ Is there a clean data structure or an efficient for doing doing this search ? The Json could be huge with memory leaks, I want it to be as fast as possible.</p>
  <p>2/ I know this is not precise, but it could work. So do you have any suggestion how to to it or how would you do it ?</p>
  <p>3/ The operation is going to be costly because I have to parse this xlsx file, and in the mean time I have to parse the JSON to do my dictionary thing, do you have any advice ?
  I suppose I should to both parsing in a stream way so I only parse one row of the xlsx at a time, and I make my JSON parsing and research of that row before jumping to the next one ?</p>
  <p>Here is the start of the parsing code.</p>
  <pre><code>const ExcelJS = require('exceljs');
  const { FILE_EXTESTIONS } = require('../constants');
  const { allowExtention } = require('../helpers');
  
  const executeXlsxParsing = () =&gt; {
  
     const filePath = process.argv.slice(2)[1];
     const workbook = new ExcelJS.Workbook();
     const isAllowed = allowExtention(FILE_EXTESTIONS.xlsx, filePath)
  
     if (!filePath || !isAllowed) return;
  
     return workbook.xlsx.readFile(filePath).then(() =&gt; {
        var inboundWorksheet = workbook.getWorksheet(1);
        inboundWorksheet.eachRow({ includeEmpty: true }, (row, rowNumber) =&gt; {
           console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
        });
     });
  };
  
  
  module.exports.executeXlsxParsing = executeXlsxParsing();
  </code></pre>
  <p><a href="https://i.stack.imgur.com/okKka.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/okKka.png" alt="xlsx file example" /></a></p>
  <p>Thank you all :)</p>