in reply to Re^2: Data validation and blank spaces in tab formatted csv file
in thread Data validation and blank spaces in tab formatted csv file
There are several approaches. You can skip those spaces while parsing resulting in empty fields:
my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => "\t", auto_diag => 1, allow_whitespace => 1, });
but as you are dealing with tab separated data, I'd personally would coose to do it inside the loop
while (my $row = $csv->getline ($fh)) { # Check if the 5th field contains data if ($row->[4] =~ m/\S/) { # more than just whitespace $csv_o->print ($fhv, $row); } else { # sorry, this is not filled: invalid $csv_o->print ($fhi, $row); }
Enjoy, Have FUN! H.Merijn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Data validation and blank spaces in tab formatted csv file
by Ma (Novice) on Oct 24, 2013 at 15:34 UTC | |
Re^4: Data validation and blank spaces in tab formatted csv file
by Ma (Novice) on Oct 24, 2013 at 15:54 UTC | |
by Anonymous Monk on Oct 24, 2013 at 17:31 UTC | |
Re^4: Data validation and blank spaces in tab formatted csv file
by Ma (Novice) on Oct 24, 2013 at 17:45 UTC | |
by Tux (Canon) on Oct 25, 2013 at 06:24 UTC |
In Section
Seekers of Perl Wisdom