in reply to Re: insert null in missing places of csv
in thread insert null in missing places of csv
Note that this approch changes both 1,2,,3,4 and 1,2,"",3,4 to 1,2,NULL,3,4.
The safe way would be
$ cat test.pl use 5.18.2; use warnings; use Text::CSV_XS qw( csv ); csv (in => csv ( in => *ARGV, blank_is_undef => 1, on_in => sub { $_ //= "NULL" for @{$_[1]}; }, ), ); $ cat test.csv 1,2,,3,4 1,2,"",3,4 $ perl test.pl test.csv 1,2,NULL,3,4 1,2,,3,4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: insert null in missing places of csv
by ukhare (Novice) on Feb 20, 2016 at 07:53 UTC | |
by Tux (Canon) on Feb 20, 2016 at 10:52 UTC | |
by hippo (Archbishop) on Feb 20, 2016 at 09:38 UTC | |
by ukhare (Novice) on Feb 20, 2016 at 10:12 UTC | |
by poj (Abbot) on Feb 20, 2016 at 10:48 UTC | |
by choroba (Cardinal) on Feb 20, 2016 at 18:08 UTC | |
by AnomalousMonk (Archbishop) on Feb 20, 2016 at 15:34 UTC |