diff --git a/modules/util/Util/Simple_CSV.pm b/modules/util/Util/Simple_CSV.pm index 5edd1d9f0a38759b0c207e04f10e494bed401f6a..a26cc8c520eee81c01c273c5fb701ec4ccebb34c 100644 --- a/modules/util/Util/Simple_CSV.pm +++ b/modules/util/Util/Simple_CSV.pm @@ -166,6 +166,15 @@ sub load_csv_file return undef unless (defined ($fi_open)); + if (exists($obj->{skip})) + { + my $skip= $obj->{skip}; + if ($skip =~ /^\d+$/ && $skip > 0) + { + while ($skip-- > 0) { <FI>; } # skip a number of lines + } + } + $obj->load_csv_file_headings (*FI) unless ($obj->{'no_headings'}); if (@{$obj->{columns}} # NOTE: columns might have been defined using $obj->define_columns(...) diff --git a/modules/util/csv.pl b/modules/util/csv.pl index 666ea34be119d581929448edb997f2c5ceedebd5..aa35bbd1b18cea8ecaafd354408e0c536649d8d4 100755 --- a/modules/util/csv.pl +++ b/modules/util/csv.pl @@ -98,6 +98,7 @@ my $view= 'matrix'; # values: matrix, extended, header, json, dumper my $all= 0; # for extend view, sofar... my $find_pattern= undef; # this is used for a pattern match my $search_string= undef; # this is used to select a certain value in a column +my $skip= undef; # used for option --in <fieldname> <field_value>+ my @search_strings; @@ -121,6 +122,7 @@ while (defined (my $arg= shift (@ARGV))) if ($opt eq 'merge') { $op_mode= 'merge'; $view= 'no'; } elsif ($opt eq 'dump') { $DUMP_FILE= $val || shift (@ARGV); } elsif ($opt eq 'out') { $out_file= $val || shift (@ARGV); } + elsif ($opt eq 'skip') { $skip= $val || shift (@ARGV); } elsif ($opt eq 'find') { $find_pattern= $val || shift (@ARGV); } # TODO: allow multiple patterns! elsif ($opt eq 'search' || $opt eq 'select') { # TODO: allow multiple searches! @@ -337,10 +339,8 @@ EOX $csv->set ('fidef' => \&fidef3); } -if (defined ($max_items)) -{ - $csv->set ( max_items => $max_items ); -} +$csv->set ( max_items => $max_items ) if (defined ($max_items)); +$csv->set ( skip => $skip ) if (defined ($skip)); my $fnm= shift (@PARS); $csv->load_csv_file ($fnm);