title: Javascript: Read text file into a matrix
body: <p>I would like to read a text file with numbers and put them into a matrix using JavaScript</p>
  
  <p>I know how to load, and read the file and even show the contents with the alert, but I have no idea how to put the contents into a matrix. I've been using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader" rel="nofollow">FileReader API</a>.</p>
  
  <p>My idea is to get the numbers and use with Babylon.js so I can plot points into the canvas</p>
  
  <p>Also another problem is that I want to skip a lot of lines and start to read from an exact word, is that even possible on JavaScript?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>&lt;input type="file" id="fileinput" /&gt;
  &lt;script type="text/javascript"&gt;
      if (window.File &amp;&amp; window.FileReader &amp;&amp; window.FileList &amp;&amp; window.Blob) {
          function readSingleFile(evt) {
              var f = evt.target.files[0]; 
  
              if (f) {
                  var r = new FileReader();
                  var contents = 'empty';
                  r.onload = function(e) { 
                      contents = e.target.result;
                      alert( "File loaded:" + f.name + "\n"); 
                      alert(contents); 
                  }
              r.readAsText(f);
              } else { 
                  alert("Failed");
              }
          }
  
          document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
      } else {
          alert('The File APIs are not fully supported by your browser.');
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>After reading the file, I want to put these numbers:</p>
  
  <pre><code>2.50000000000000E+0002 -2.00000000000000E+0002 2.00000000000000E+0001 3.09941176470588E+0002 -1.59941176470588E+0002 8.58823529411765E+0001 0.00000000000000E+0000 0.00000000000000E+0000 1.00000000000000E+0000
  </code></pre>
  
  <p>Into a matrix[x][9], where x is the number of lines on the file.</p>
  
  <p>The first six numbers represents a coordinate (x, y, z) in the canvas, the last three represents the object color</p>
  
  <p><strong>EDIT 2:</strong>
  The request from @NOBrien
  The file is basically like this:</p>
  
  <pre><code>NUM_GRUPOS 1
  [GRUPO]
  TAM 64
  [PONTOS]
  ROTULO 1
   2.50000000000000E+0002 -2.00000000000000E+0002  2.00000000000000E+0001  0.00000000000000E+0000  0.00000000000000E+0000  1.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000
  ROTULO 2
   3.54000000000000E+0002 -2.52000000000000E+0002  3.90000000000000E+0002  1.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000  0.00000000000000E+0000
  ... //A bunch of other numbers
  [ARESTAS]
  TAM 60
   2.50000000000000E+0002-2.00000000000000E+0002 2.00000000000000E+0001 3.09941176470588E+0002-1.59941176470588E+0002 8.58823529411765E+0001 0.00000000000000E+0000 0.00000000000000E+0000 1.00000000000000E+0000
  </code></pre>
  
  <p>I want to skip all these first lines and start reading from the <strong><em>[ARESTAS]</em></strong> keyword, I also need to get the number after the word <strong><em>TAM</em></strong> </p>
  
  <p>Is that even possible?</p>