I have a CSV file whith this kind of lines:
1,New York city,8175133,40.71455,-74.007124
2,Los Angeles city,3792621,34.05349,-118.245323
I'm doing this method to split it:
function processData(csv) {
var allTextLines = csv.split(/\r\n|\n/);
var lines = [];
while (allTextLines.length) {
lines.push(allTextLines.shift().split(','));
}
console.log(lines);
drawOutput(lines);
}
But it doesn't work like the way I want. I would like just a part of the string and not teh whole line:
lines[0] = New York City, 40.71455, -74.007124
lines[1] = Los Angeles city, 34.05349, -118.245323
Is it possible? How Can I split it that way? Already tried a few things, but I didn't find yet a good way to do it.