I am trying to split several hundred lines read from a CSV file on ,
. E.g.:
"Acme services","Sesame street","zip","0,56","2013-10-21"
"Black adder, intra-national Association","shaftsville rd","zap code","0,50","2014-10-14"
etc.
I could split the first row on ,
, but this would not work for the second row. However, if I split on ,
then I would trap these cases. I could then remove the " using simple regex (e.g. $col[i] =~ s/\"+//g
)
I have tried @cols = split(/\",\"/,$line)
, and I've tried split('","',$lines)
and various variations, but every time, I get the full $line
in $col[0]
, with $cols[1:n]
as empty.
Any help would be much appreciated! Thanks.