Quantcast
Channel: [Q&A - FAQ Neotys] Last questions
Viewing all articles
Browse latest Browse all 2283

File reader error in javascript

$
0
0

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);

}


Viewing all articles
Browse latest Browse all 2283

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>