So, here is my problem: I have a large text file (size around 150 MB) with hundreds of thousands of lines.I need to read the contents of the file, parse it so that the lines are put in appropriate html tags and write it into a window.document.open() object.
My code works for files until 50 MB of size.
var rawFile=new XMLHttpRequest();
rawFile.open("GET",file, true);
rawFile.onreadystatechange= function () {
if (rawFile.readyState === 4) {
if (rawFile.status === 200 || rawFile.status === 0) {
var allText = rawFile.responseText;
var contents = allText.split("\n");
var w = window.open();
w.document.open();
for (i = 0; i < contents.length; i++) {
//logc so that str= appropriate tags + contents[i]
w.document.write(str);
}
}
}
}
The code works. The logic works. But if the file size is greater than 100MB or similar, chrome crashes. I think reading the file in chunks and then writing it to window.document.open() will remove this problem for me.
any advice how I could go about accomplishing this is very appreciated. Thank you :)
(Ignore if there are any errors in the code I posted above, my actual code is very large so I just wrote a miniature version of it)