title: Uncaught TypeError: Cannot read property 1 of null when using row.match
body: <p>I have some code that I am working on that is meant to try and read from a name of a variable and a value from a csv file and pass it through to two separate arrays. I am getting an error that says:</p>
  <pre><code>Uncaught TypeError: Cannot read property '1' of null
      at eval (eval at runAction (out1.js:254), &lt;anonymous&gt;:36:35)
      at Array.forEach (&lt;anonymous&gt;)
      at Object.onCompleted (eval at runAction (out1.js:254), &lt;anonymous&gt;:29:17)
      at e (out1.js:218)
      at FileReader.l.onloadend (out1.js:218)
  </code></pre>
  <p>The code I have written so far is:</p>
  <pre><code>openFile({
      read: &quot;Text&quot;,
      multiple: false,
      onCompleted: function(result){
          alert(result.contents);
          var name = [];
          var value = [];
          var i = 0, j = 0;
          
          var string = result.contents;
          var csvRows = string.split(/;|\n/); 
          
          var varNames = [];
          var varVals = [];
  
          csvRows.forEach(row =&gt; {
             
              
              var rowParts = row.match(/(.+),\s?(.+)/);
              
              // push adds the element to the end of the array
              // rowParts[0] is the whole match so rowParts[1] is the varName
              
              varNames.push(rowParts[1]);
              varVals.push(rowParts[2]);
          })
          for (i = 0; i &lt; varNames.length; i++){
              alert(varNames[i]);
          }
          }})
  </code></pre>
  <p>The error seems to be appearing in this line because when I change the value inside the square brackets the '1' changes to whatever the number is changed to:</p>
  <pre><code>varNames.push(rowParts[1]);
  varVals.push(rowParts[2]);
  </code></pre>
  <p>The csv file that I am trying to import is formatted as such:</p>
  <pre><code>&quot;Variable Name 1&quot;, &quot;Value 1&quot;
  &quot;Variable Name 2&quot;, &quot;Value 2&quot;
  &quot;Variable Name 3&quot;, &quot;Value 3&quot;
  </code></pre>
  <p>For example, I have 3 variables called &quot;a variable, b variable, c variable&quot; and they have the values, &quot;1,2,3&quot; respectively.</p>
  <p>The code is written in a web app that has a separate API and only uses the base javascript for what I am using at the moment. I have tried different methods and have come up against the same error. If anyone knows how to solve this issue it would be greatly appreciated.</p>