logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Exporter::TSV - a tab-delimited TSV exporter

Configuration

       file
           Write  output to a local file given by its path or file handle.  Alternatively a scalar reference can
           be passed to write to a string and a code reference can be used to write to a callback function.

       fh  Write the output to an IO::Handle. If not specified, Catmandu::Util::io is used to create the  output
           handle from the "file" argument or by using STDOUT.

       fix An ARRAY of one or more fixes or file scripts to be applied to exported items.

       encoding
           Binmode of the output stream "fh". Set to "":utf8"" by default.

       fields
           See Catmandu::TabularExporter.

       columns
           See Catmandu::TabularExporter.

       header
           Include a header line with column names. Enabled by default.

       sep_char
           Column separator ("tab" by default)

Description

       This "Catmandu::Exporter" exports items as rows with tab-separated values (TSV). A header line with field
       names will be included if option "header" is set. See Catmandu::TabularExporter on how to configure the
       field mapping and column names. Newlines and tabulator values in field values are escaped as "\n", "\r",
       and "\t".

       Hint: by default, the exporter will output all the fields that are found in the first record of the data
       input. This can be changed by setting the "fields" option of the exporter.

Methods

       See      Catmandu::TabularExporter,     Catmandu::Exporter,     Catmandu::Addable,     Catmandu::Fixable,
       Catmandu::Counter, and Catmandu::Logger for a full list of methods.

Name

       Catmandu::Exporter::TSV - a tab-delimited TSV exporter

See Also

       Catmandu::Importer::TSV

perl v5.40.0                                       2025-01-17                       Catmandu::Exporter::TSV(3pm)

Synopsis

           # From the command line

           # Provide a hint to the exporter which fields to export from the JSON
           # input. By default the TSV exporter will export the fields that are
           # found in the first JSON record.
           $ catmandu convert JSON to TSV --fields "id,title,year" < data.json

           # In a Perl script

           use Catmandu;

           my $exporter = Catmandu->exporter(
                       'TSV',
                       fix => 'myfix.txt',
                       fields => "f1,f2,f3",
                       header => 1);

           my $exporter = Catmandu->exporter(
                       'TSV',
                       fields => [qw(f1 f2 f3)]);

           $exporter->add_many($arrayref);
           $exporter->add_many($iterator);
           $exporter->add_many(sub { });

           $exporter->add($hashref);

           printf "exported %d items\n" , $exporter->count;

See Also