I am trying to load a file that has about 100k in lines and so far the browser has been crashing ( locally ). I looked on the internet and saw Papa Parse seems to handle large files. Now it is reduced down to about 3-4 minutes to load into the textarea. Once the file is loaded, I then want to do some more jQuery to do counts and things so the process is taking awhile. Is there a way to make the csv load faster? Am I using the program correctly?
<div id="tabs">
<ul>
<li><a href="#tabs-4">Generate a Report</a></li>
</ul>
<div id="tabs-4">
<h2>Generating a CSV report</h2>
<h4>Input Data:</h4>
<input id="myFile" type="file" name="files" value="Load File" />
<button onclick="loadFileAsText()">Load Selected File</button>
<form action="./" method="post">
<textarea id="input3" style="height:150px;"></textarea>
<input id="run3" type="button" value="Run" />
<input id="runSplit" type="button" value="Run Split" />
<input id="downloadLink" type="button" value="Download" />
</form>
</div>
</div>
$(function () {
$("#tabs").tabs();
});
var data = $('#input3').val();
function handleFileSelect(evt) {
var file = evt.target.files[0];
Papa.parse(file, {
header: true,
dynamicTyping: true,
complete: function (results) {
data = results;
}
});
}
$(document).ready(function () {
$('#myFile').change(function(handleFileSelect){
});
});
function loadFileAsText() {
var fileToLoad = document.getElementById("myFile").files[0];
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var textFromFileLoaded = fileLoadedEvent.target.result;
document.getElementById("input3").value = textFromFileLoaded;
};
fileReader.readAsText(fileToLoad, "UTF-8");
}