How can I read a huge text file line by line through javascript or jquery? I cant read all and split to an array because it will require lots of memmory. I just want to stream it...
EDIT As a note I am working on a google chrome extension so that solutions with fso ActiveX does not work on this browser. Any other ideas?
HTML5 finally provides a standard way to interact with local files, via the File API specification. As example of its capabilities, the File API could be used to create a thumbnail preview of images as they're being sent to the server, or allow an app to save a file reference while the user is offline. Additionally, you could use client-side logic to verify an upload's mimetype matches its file extension or restrict the size of an upload.
The spec provides several interfaces for accessing files from a 'local' filesystem: 1.File - an individual file; provides readonly information such as name, file size, mimetype, and a reference to the file handle. 2.FileList - an array-like sequence of File objects. (Think or dragging a directory of files from the desktop). 3.Blob - Allows for slicing a file into byte ranges.
When used in conjunction with the above data structures, the FileReader interface can be used to asynchronously read a file through familiar JavaScript event handling. Thus, it is possible to monitor the progress of a read, catch errors, and determine when a load is complete. In many ways the APIs resemble XMLHttpRequest's event model.
Note: At the time of writing this tutorial, the necessary APIs for working with local files are supported in Chrome 6.0 and Firefox 3.6. As of Firefox 3.6.3, the File.slice() method is not supported.