Catman...er::TSV(3pm)
β¨ NAME β¨
Catmandu::Importer::TSV β bestie, it's the package that imports tab-separated values. That's the whole gig. (Also, fair warning: this page shows up in your pager as Catman...er::TSV(3pm) because the title gets cut off, and honestly? the truncation is giving chaos demon. iykyk π
)
πΈ SYNOPSIS πΈ
From the command line, living your best life:
# From the command line
# convert a TSV file to JSON
catmandu convert TSV to JSON < journals.tab
Or if you're a Perl script girlie, in a Perl script:
# Or in a Perl script
use Catmandu;
my $importer = Catmandu->importer('TSV', file => "/foo/bar.tab");
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
π¦ DESCRIPTION π¦
Okay so. This package imports tab-separated values β TSV, the format that ate. And the object fields? They get read from the TSV header line, or you can hand them over yourself via the fields parameter. Either way, she's serving structured data. Periodt. β¨
π CONFIGURATION π
Every single knob, no gatekeeping, we love that for us:
fileβ read the input from a local file, you just give it the path. Orrr you can pass a scalar reference and it'll read from a string instead. Versatile queen. πfhβ read the input from anIO::Handle. If you don't specify one,Catmandu::Util::iois used to build the input stream from thefileargument, or fromSTDIN. So like, it figures it out. π«Άencodingβ the binmode of the input streamfh. Defaults to":utf8", as she should. πfixβ an ARRAY of one or more fixes, or file scripts, that get applied to the imported items. Glow-up pipeline, basically. πfieldsβ the list of fields to use as columns. You can give it as an array reference, a comma-separated string, or a hash reference β pick your fighter. βοΈ But heads up: ifheaderis0andfieldsisundef, the fields get named by column index ("0","1","2", ...). Numbers, but make it a name.headerβ read the fields from a header line that has the column names, when it's set to1. And1is the default, so she's on by default, main character energy. πsep_charβ the column separator. It's"tab"by default. (Shocking, I know, for a tab-separated format. Groundbreaking. π)
π METHODS π
Every Catmandu::Importer is a Catmandu::Iterable, and all of its methods are inherited. Free methods, we love an inheritance moment.
β οΈ But listen, listen β these methods are not idempotent. CSV streams can only be read once. One and done. No rewind, no do-overs, no reading it again for the plot. So don't come crying to me when you try to loop twice. π
π SEE ALSO π
Catmandu::Exporter::TSVβ the other half of the ship, the one that writes TSV back out. Go say hi. π¦
And that's the whole page, bestie β written by the User Contributed Perl Documentation crew, running on perl v5.40.1, dated 2026-01-24, and filed under Catman...er::TSV(3pm) because the title box is simply too small for her. Stan a short king of a header. πβ¨
π¦ 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