Closed osm-ToniE closed 5 years ago
I will not completely change the code, because much of existing CSV would need to be changed, example from "Flixbus"
P1;bus;;Danzig;Warschau;"PolskiBus" Souter Holdings Poland Sp. z o. o.
Actually, there is currently only one example where "ref-separator" would need to be equal to "separator"
VRS:
"S23;RB23";train;Voreifelbahn;Bonn Hbf;Euskirchen
So, the suggested solution above is only used when "separator" is equal to "ref-separator" or "or-separator".
Otherwise, the current code with split(...)
is used.
The solution will be:
use csvsplit()
if the line
-- includes quote followed by $separator or
-- starts with a quote or
-- ends with a quote
--- this will cover both examples above
use split()
otherwise
Try one of the solutions below
my $csv = Text::CSV->new({ sep_char => ',' });
my @fields = Text::ParseWords::parse_line(';', 0, $line);
From stackoverflow