App-CSVUtils

 view release on metacpan or  search on metacpan

script/csv-cmp  view on Meta::CPAN

See examples in the L</EXAMPLES> section.

=head1 DESCRIPTION

This utility is modelled after the Unix command C<cmp>; it compares two CSV files
value by value and ignore quoting (and can be instructed to ignore whitespaces,
case difference).

If all the values of two CSV files are identical, then utility will exit with
code 0. If a value differ, this utility will stop, print the difference and exit
with code 1.

If C<-l> (C<--detail>) option is specified, all differences will be reported. Note
that in C<cmp> Unix command, the C<-l> option is called C<--verbose>. The detailed
report is in the form of CSV:

 rownum,fieldnum,value1,value2

where C<rownum> begins at 1 (for header row), C<fieldnum> begins at 1 (first
field), C<value1> is the value in first CSV file, C<value2> is the value in the
second CSV file.

Other notes:

=over

=item * If none of the field selection options are used, it means all fields are
included (equivalent to C<--include-all-fields>).

=item * Field selection will be performed on the first CSV file, then the indexes will
be used for the second CSV file.

=back

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--detail>, B<-l>

Report all differences instead of just the first one.

=item B<--ignore-case>, B<-i>

Ignore case difference.

=item B<--ignore-leading-ws>

Ignore leading whitespaces.

=item B<--ignore-trailing-ws>

Ignore trailing whitespaces.

=item B<--ignore-unknown-fields>

When unknown fields are specified in --include-field (--field) or --exclude-field options, ignore them instead of throwing an error.

=item B<--ignore-ws>

Ignore leading & trailing whitespaces.

=item B<--input-skip-num-lines>=I<s>

Number of lines to skip before header row.

This can be useful if you have a CSV files (usually some generated reports,
sometimes converted from spreadsheet) that have additional header lines or info
before the CSV header row.

See also the alternative option: C<--input-skip-until-pattern>.


=item B<--input-skip-until-pattern>=I<s>

Skip rows until the first header row matches a regex pattern.

This is an alternative to the C<--input-skip-num-lines> and can be useful if you
have a CSV files (usually some generated reports, sometimes converted from
spreadsheet) that have additional header lines or info before the CSV header
row.

With C<--input-skip-num-lines>, you skip a fixed number of lines. With this
option, rows will be skipped until the first field matches the specified regex
pattern.


=item B<--quiet-arg>, B<-q>

Do not report, just signal via exit code.

=item B<--show-selected-fields>

Show selected fields and then immediately exit.

=back

=head2 Field selection options

=over

=item B<--exclude-all-fields>

Shortcut for --exclude-field-pat=.*, effectively excluding all fields.

See C<--exclude-field-pat>.

=item B<--exclude-field-pat>=I<s>

Field regex pattern to exclude, takes precedence over --field-pat.

=item B<--exclude-field>=I<s@>, B<-F>

Field names to exclude, takes precedence over --fields.

Can be specified multiple times.



( run in 0.467 second using v1.01-cache-2.11-cpan-39bf76dae61 )