Catman...er::TSV(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ 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 an IO::Handle. If you don't specify one, Catmandu::Util::io is used to build the input stream from the file argument, or from STDIN. So like, it figures it out. 🫢
  • encoding β€” the binmode of the input stream fh. 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: if header is 0 and fields is undef, 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 to 1. And 1 is 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