I just noticed that the FileReader API
skips the handleFiles(appCSV)
and returns undefined
instead.
appDictionary = handleFiles(appCSV);
dbDictionary = handleFiles(dbCSV);
My appCSV
file size is just 2584729 bytes
or only about 2.5 MB
. Is the issue due to that?
This is strange since I am already using Chrome 57
.
Kindly help me investigate and provide solutions or workarounds. Thanks!
Body of the handleFiles
function:
function handleFiles(files) {
// Check for the various File API support.
if (window.FileReader) {
// FileReader are supported.
getAsText(files[0]);
} else {
alert('FileReader are not supported in this browser.');
}
}
function getAsText(fileToRead) {
let reader = new FileReader();
// Handle errors load
reader.onload = loadHandler;
reader.onerror = errorHandler;
// Read file into memory as UTF-8
reader.readAsText(fileToRead);
}
function loadHandler(event) {
let csv = event.target.result;
processDataToDictionary(csv);
}
function errorHandler(evt) {
if (evt.target.error.name == "NotReadableError") {
alert("Cannot read file!");
}
}