I have to generate an 80x250,000 CSV through a browser. Handling this much data is somewhat slow but manageable in arrays, but I have a problem when I try to generate a CSV string to turn into a Blob.
Solutions such as this: https://stackoverflow.com/a/25975345 involve creating a large string of the CSV contents. I cannot create such a string without crashing the browser. How can I generate a file this large? Below is the code I'm currently using to benchmark this:
var fileData = "contents:text/csv;base64,";
for(var i = 0, temp; i < 150000; i++){
for(var j = 0; j < 80; j++){
fileData += Math.random() + ",";
}
fileData += "\r\n";
}
var exportLink = document.createElement('a');
var csvData = new Blob([window.btoa(fileData)], { type: "text/csv" });
var csvUrl = URL.createObjectURL(csvData);
exportLink.href = csvUrl;