title: Read FileReader object line-by-line without loading the whole file into RAM
body: <p>Now that many browsers support reading local files with HTML5's FileReader, this opens the door to websites which go beyond 'database front-ends' into scripts which can do something useful with local data without having to send it up to a server first.</p>
  
  <p>Pre-processing images and video before upload aside, one big application of FileReader would be loading data from some kind of on-disk table (CSV, TSV, whatever) into the browser for manipulation - perhaps for plotting or analysis in D3.js or creating landscapes in WebGL.</p>
  
  <p>Problem is, most examples out there on StackOverflow and other sites use FileReader's .readAsText() property, which reads the whole file into RAM before returning a result.</p>
  
  <p><a href="https://stackoverflow.com/questions/15287573">javascript: how to parse a FileReader object line by line</a></p>
  
  <p>To read a file without loading the data into RAM, one would need to use .readAsArrayBuffer(), and this SO post is the closest I can get to a good answer:</p>
  
  <p><a href="https://stackoverflow.com/questions/25810051">filereader api on big files</a></p>
  
  <p>However, it's a bit too specific to that particular problem, and in all honesty, I could try for days to make the solution more general, and come out empty handed because I didn't understand the significance of the chunk sizes or why Uint8Array is used. A solution to the more general problem of reading a file line-by-line using a user-definable line separator (ideally with .split() since that also accept regex), and then doing something per-line (like printing it to the console.log) would be ideal.</p>