Catmandu::Importer::TSV(3pm)

Catmandu::Importer::TSV3pm

Package that imports tab-separated values

Usage

    # From the command line
    # convert a TSV file to JSON
    catmandu convert TSV to JSON < journals.tab
    # Or in a Perl script
    use Catmandu;
    my $importer = Catmandu->importer('TSV', file => "/foo/bar.tab");
    my $n = $importer->each(sub {
        my $hashref = $_[0];
        # ...
    });

Overview

This package imports tab-separated values (TSV). The object fields are read from the TSV header line or given via the "fields" parameter.

Configuration

file

Read input from a local file given by its path. Alternatively a scalar reference can be passed to read from a string.

fh

Read input from an IO::Handle. If not specified, Catmandu::Util::io is used to create the input stream from the "file" argument or by using STDIN.

encoding

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

fix

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

fields

List of fields to be used as columns, given as array reference, comma-separated string, or hash reference. If "header" is 0 and "fields" is "undef" the fields will be named by column index ("0", "1", "2", ...).

header

Read fields from a header line with the column names, if set to 1 (the default).

sep_char

Column separator ("tab" by default)

Methods

Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The methods are not idempotent: CSV streams can only be read once.

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.