I created a web application for cleaning CSV / TSV data. The application allows you to download a CSV file, read it, correct the data, and then download a new CSV file with the correct data. One of the problems I have encountered is downloading files with over 2500 lines. The browser crashes with the following error message:
"Aw, Snap! Something went wrong while displaying this webpage..."
To get around this, I changed the program to download several CSV files, not exceeding 2500 lines, until all the data was downloaded. Then I would collect the downloaded CSV files into the final file. This is not the solution I'm looking for. When working with files with more than 100,000 lines, I need to load all the contents into 1 file, not 40. I also need to have an interface solution.
Below is the code to download the CSV file. I create a hidden link encoding the contents of the data array (each element has 1000 lines) and creates a path for the hidden link. Then I launch a click on the link to start the download.
var startDownload = function (data){ var hiddenElement = document.createElement('a'); var path = 'data:attachment/tsv,'; for (i=0;i<data.length;i++){ path += encodeURI(data[i]); } hiddenElement.href = path; hiddenElement.target = '_blank'; hiddenElement.download = 'result.tsv'; hiddenElement.click(); }
In my case, the above process works for ~ 2500 rows at a time. If I try to download large files, the browser crashes. What am I doing wrong, and how can I upload large files without browser crashes? The file that the browser breaks has (12,000 rows in 48 columns)
ps I do all this in Google Chrome, which allows me to upload files. Therefore, the solution should work in Chrome.