I am reading a csv file in javascript by first spliting by newline then spiliting by comma. I am able to parse the whole of csv successfully but only one thing is left. i.e. the last one
I don't know how to remove those \r . The code I am using is
function csvJSON(csv){
var lines=csv.split("\n");
var result = [];
var headers=lines[0].split(",");
for(var i=1;i<lines.length;i++){
var obj = {};
var currentline=lines[i].split(",");
for(var j=0;j<headers.length;j++){
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
return result; //JavaScript object
}