I have a problem with split and I don't know how to solve it.
I want to split a CSV file, avoiding some ' " ' chars, and it's working fine, but some of the lines have text like the next example:
Robert, Pattinson, rober@company.com, "London street, 19", London
It splits like this:
Robert
Pattinson
rober@company.com
london street
19
London
And I want to split it like this:
Robert
Pattinson
rober@company.com
London street, 19
London
Here is the command I use for this:
let content = (evt.target as FileReader).result.toString().replace(/["]/g,'');
How can I fix this?
Thanks in advance.
EDIT:
I just noticed I forgot to include the entire code to split, here it is:
let content = (evt.target as FileReader).result.toString().replace(/["]/g,'');
let lines = content.split('\n');
let commaSeparated = lines.map(function(line) {
return line.split(',');
});