Catman...er::TSV(3pm)
π NAME π
ok so bestie, meet Catmandu::Exporter::TSV β a tab-delimited TSV exporter π (yes it's a Catmandu::Exporter, it lives in the perl 3pm manual pages, and it's here to make tabs happen)
β¨ SYNOPSIS β¨
first up, from the command line π
# 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
and then in a Perl script, because we contain multitudes π¦
# 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;
π DESCRIPTION π
This Catmandu::Exporter exports items as rows with tab-separated values (TSV). no cap, that's literally the whole vibe. π§
A header line with field names will be included if option header is set. if you wanna know how to configure the field mapping and the column names, go look at Catmandu::TabularExporter, she's the one with the answers. π
Newlines and tabulator values in field values are escaped as "\n", "\r", and "\t". so no, a rogue tab in your data can't come for your columns' lives. protected. π«Ά
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. (yes this is a hint, take it, it's free)
πΈ 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. choose your fighter β¨fhβ Write the output to anIO::Handle. If not specified,Catmandu::Util::iois used to create the output handle from the"file"argument or by usingSTDOUT. default behaviour is givingSTDOUT, iconic tbhfixβ AnARRAYof one or more fixes or file scripts to be applied to exported items. glow-up pipeline πencodingβ Binmode of the output stream"fh". Set to":utf8"by default. (that's":utf8"with the quotes, she's specific like that)fieldsβ SeeCatmandu::TabularExporter. (she explains it better, iykyk)columnsβ SeeCatmandu::TabularExporter. (same bestie, same)headerβ Include a header line with column names. Enabled by default. πsep_charβ Column separator ("tab"by default) β yes you can change it, but like... it's a TSV exporter. live your truth i guess π¦
π METHODS π
See Catmandu::TabularExporter, Catmandu::Exporter, Catmandu::Addable, Catmandu::Fixable, Catmandu::Counter, and Catmandu::Logger for a full list of methods.
that's the whole squad fr fr β go read them if you want the full method menu π
π SEE ALSO π
Catmandu::Importer::TSVβ the other half of the ship, the one that reads them back in π
and that's the tea, bestie π this page ships with perl v5.40.1, dated 2026-01-24, from the User Contributed Perl Documentation corner of the manual, filed under Catmandu::Exporter::TSV in section 3pm β go forth and tab-separate π
β¨
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms