On Thu, 24 Mar 2016 05:32:37 -0400, "Neil_Bowers via RT"
<bug-Text-CSV_XS@rt.cpan.org> wrote:
Show quoted text> I use the csv () function a lot, and recently have wished there was an option to specify that blank lines are skipped
>
> csv (skip => 'blank', in => $fh, ...);
>
> There are two main cases that I'd like to skip:
Use filter =>
$ cat test.csv
1,2,,3,4
a,b,c,,
,
d,e,,,t
,,
f,g,h,i,j
$ perl -MCSV -wE'csv (in => "test.csv")'
1,2,,3,4
a,b,c,,
,
d,e,,,t
,,
f,g,h,i,j
Show quoted text> 1. blank lines. Ie no sep_char seen, and nothing other than whitespace perhaps
$ perl -MCSV -wE'csv (in => "test.csv", filter => { 0 => sub { "@{$_[1]}" ne "" }})'
1,2,,3,4
a,b,c,,
,
d,e,,,t
,,
f,g,h,i,j
Show quoted text> 2. effectively empty lines: the only character seen is sep_char
$ perl -MCSV -wE'csv (in => "test.csv", filter => { 0 => sub { grep /\S/, @{$_[1]} }})'
1,2,,3,4
a,b,c,,
d,e,,,t
f,g,h,i,j
Is that enough rope to tie the required knots?
--
H.Merijn Brand
http://tux.nl Perl Monger
http://amsterdam.pm.org/
using perl5.00307 .. 5.23 porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/