App-CSVUtils

 view release on metacpan or  search on metacpan

script/csv-concat  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /App/CSVUtils/csv_concat/csv_concat
# and generated automatically using Perinci::CmdLine::Gen version 0.502

use 5.010001;
use strict;
use warnings;
use Log::ger;

use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2026-07-09'; # DATE
our $DIST = 'App-CSVUtils'; # DIST
our $VERSION = '1.038'; # VERSION

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/CSVUtils/csv_concat/csv_concat",
    program_name => "csv-concat",
    log => 1,
    read_config => 0,
    read_env => 0,
    use_utf8 => 1,
);

$cmdline->run;

# ABSTRACT: Concatenate several CSV files together, collecting all the fields
# PODNAME: csv-concat

__END__

=pod

=encoding UTF-8

=head1 NAME

csv-concat - Concatenate several CSV files together, collecting all the fields

=head1 VERSION

This document describes version 1.038 of csv-concat (from Perl distribution App-CSVUtils), released on 2026-07-09.

=head1 SYNOPSIS

B<csv-concat> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)

B<csv-concat> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

B<csv-concat> [B<L<--debug|/"--debug">>|B<L<--log-level|/"--log-level=s">>=I<level>|B<L<--quiet|/"--quiet">>|B<L<--trace|/"--trace">>|B<L<--verbose|/"--verbose">>] [B<L<--format|/"--format=s">>=I<name>|B<L<--json|/"--json">>] [B<L<--inplace|/"--inpla...

=head1 DESCRIPTION

Example, concatenating this CSV:

 col1,col2
 1,2
 3,4

and:

 col2,col4
 a,b
 c,d
 e,f

and:

 col3
 X
 Y

will result in:

 col1,col2,col4,col3
 1,2,
 3,4,
 ,a,b
 ,c,d
 ,e,f
 ,,,X
 ,,,Y

When C<--overlay> option is enabled, the result will be:

 col1,col2,col4,col3
 1,2,b,X
 3,4,d,Y
 ,e,f,

When C<--overlay> as well as C<--overwrite-fields> option are enabled, the result
will be:

 col1,col2,col4,col3
 1,a,b,X
 3,c,d,Y
 ,e,f,

Keywords: join, merge, overlay

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--overlay>

Whether to overlay rows from second and subsequent CSV files to the first.

By default, rows from the second CSV file will be added after all the rows from
the first CSV are added, and so on. However, when this option is enabled, the
rows the second and subsequent CSV files will be added together (overlaid). See
the utility's example for an illustration.

See also the C<--overwrite-fields> option.


=item B<--overwrite-fields>

Whether fields from subsequent CSV files should overwrite existing fields from previous CSV files.

When in overlay mode (C<--overlay>), by default the value for a field is
retrieved from the first CSV file that has the field. With C<--overwrite-fields>
option enabled, the value will be retrieved from the last CSV that has the
field. See the utility's example for an illustration.


=back

=head2 Input options

=over

=item B<--input-escape-char>=I<s>

Specify character to escape value in field in input CSV, will be passed to Text::CSV_XS.

Defaults to C<\\> (backslash). Overrides C<--input-tsv> option.


=item B<--input-filename>=I<s@>

Input CSV files.

Default value:

 ["-"]

Use C<-> to read from stdin.

Encoding of input file is assumed to be UTF-8.


Can also be specified as the 1st command-line argument and onwards.

Can be specified multiple times.

=item B<--input-filenames-json>=I<s>

Input CSV files (JSON-encoded).

See C<--input-filename>.

Can also be specified as the 1st command-line argument and onwards.

=item B<--input-quote-char>=I<s>

Specify field quote character in input CSV, will be passed to Text::CSV_XS.

Defaults to C<"> (double quote). Overrides C<--input-tsv> option.


=item B<--input-sep-char>=I<s>

Specify field separator character in input CSV, will be passed to Text::CSV_XS.

Defaults to C<,> (comma). Overrides C<--input-tsv> option.


=item B<--input-skip-before-num-data-rows>=I<s>

Skip a certain number of data rows for each input file.



( run in 0.383 second using v1.01-cache-2.11-cpan-a5162978ef8 )