Javascript using File.Reader () to read line by line

This question is close , but not quite enough.

In my HTML5 application, the CSV file is read (although it applies to text) and displays some data on the screen.

The problem is that CSV files can be huge (I was able to agree that a 1 GB file size would be limited). The good news is that I need to display some data from the CSV file at any time.

An idea is something like (psudeo code)

var content;
var reader =  OpenReader(myCsvFile)
var line = 0;

while (reader.hasLinesRemaning)
    if (line % 10 == 1)
      content = currentLine;
Loop to next line

There are enough articles on how to read a CSV file, I use

function openCSVFile(csvFileName){
    var r = new FileReader();
    r.onload = function(e) {
        var contents = e.target.result;
        var s = "";
    };  
    r.readAsText(csvFileName);
}

but I don’t see how to read a line at a time in Javascript or even if it is possible.

My CSV data looks like

Some detail: date, ,
More detail: time, ,
val1, val2
val11, val12
#val11, val12
val21, val22

2 , , , # (, )

, , - ?

+4
1

readLine(), . :

  • progress. , .result, XMLHttpRequest.
  • Streams API .read(size) . , .
  • Blobs slice, Blob, . , , , . .

, . , . , , , , .

. : JavaScript

+4

All Articles