ReferenceError: "FileReader" is not defined. (Script=csvfile;Line=3)
Here is my JS:
function getAsText() {
var filename="C:\\Users\\test\\Desktop\\validateCodedItems.csv";
var reader = new java.io.FileReader();
// Read file into memory as UTF-8
reader.readAsText(filename);
// Handle errors load
reader.onload = loadHandler;
reader.onerror = errorHandler;
}
function loadHandler(event) {
var csv = event.target.result;
processData(csv);
}
function processData(csv) {
var allTextLines = csv.split(/\r\n|\n/);
var lines = [];
for (var i=0; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
var tarr = [];
for (var j=0; j<data.length; j++) {
tarr.push(data[j]);
}
lines.push(tarr);
}
console.log(lines);
}
No answers
Madhuri posted a new question