remove blank lines when uploading csv files angular
<p>I got a  csv-reader directive and let's user upload a csv file. I noticed that when I upload a file with spaces between words  for example:<br>
abc<br>
abc<br>
abc  </p>

<p>abc  </p>

<p>abc  </p>

<p>this gets shown. I want to delete all the blank lines Not sure what to do.
<a href="https://i.stack.imgur.com/ZDjcT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZDjcT.png" alt="enter image description here"></a></p>

<pre><code>                var reader = new FileReader();
                reader.onload = function(e) {
                    var contents = e.target.result;
                    var rows = contents.split('\n');                

                    // Check if the last row is empty. This works
                    if(rows[rows.length-1] ===''){
                        rows.pop()
}
}


     // this doesn't work for some reason. It doesn't detect the '' in the middle of the arrays.

    for( var i=rows.length-1;i&gt;0;i--){
      if(rows[i] === ''){
        rows.splice(i,1)
      }
    }
</code></pre>