title: Read text file into array of objects in Typescript
body: <p>I want to convert the data in my text file into an array of objects, here is my data in text file:</p>
  <pre><code>DOCNO   NETAMOUNT   IREF1   IREF2   DOCDT
  001 30000   50  100 6/7/2020
  2   40000   40  90  6/7/2020
  </code></pre>
  <p>Here is my code as for now:</p>
  <pre><code>  reader.onload = (ev)=&gt;{
          const data = reader.result;
          var txtData = data.toString()
          console.log(data,&quot;txt data&quot;)
          var lines = txtData.split(' ');
          for(var line = 0; line &lt; lines.length; line++){
              console.log(lines[line]);
          }
      
       };
      
       reader.readAsText(file)
  }
  </code></pre>
  <p>I want to convert into a format like this:</p>
  <p><strong>0: {DOCNO: &quot;001&quot;, NETAMOUNT: &quot;30000&quot;, IREF1: &quot;50&quot;, IREF2: &quot;100&quot;, DOCDT: &quot;6/7/20&quot;}</strong></p>
  <p><strong>1: {DOCNO: &quot;2&quot;, NETAMOUNT: &quot;40000&quot;, IREF1: &quot;40&quot;, IREF2: &quot;90&quot;, DOCDT: &quot;6/7/20&quot;}</strong></p>