in reply to Add Quotes to entries in a file
But, but, but, what if any of those fields is already quoted? And what if that field contains a ;?
use Text::CSV_XS "csv"; csv (in => csv (in => *DATA, sep => ";"), sep => ";", quote_always => +1, out => \my $out); print $out =~ s/^"([^"]*)"/$1/grm; __END__ ABC;123;;;;;HELLO; DEF;345;;BANANA;12DEF;44,55;4*12;;;;;;;;3;
-->
$ perl test.pl ABC;"123";"";"";"";"";"HELLO";"" DEF;"345";"";"BANANA";"12DEF";"44,55";"4*12";"";"";"";"";"";"";"";"3"; +""
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Add Quotes to entries in a file
by AnomalousMonk (Archbishop) on Jul 12, 2018 at 15:57 UTC |