Catman...::Table(3pm)

πŸ’– NAME πŸ’–

okay so bestie, welcome to the manual page for Catmandu::Exporter::Table β€” the ASCII/Markdown table exporter. It lives in the Perl docs as Catman...::Table(3pm) and it is, no exaggeration, the moment. 🫢


✨ SYNOPSIS ✨

With the catmandu command line client πŸŽ€

echo '{"one":"my","two":"table"} {"one":"is","two":"nice"}' | \
catmandu convert JSON --multiline 1 to Table
| one | two   |
|-----|-------|
| my  | table |
| is  | nice  |
catmandu convert CSV to Table --fields id,name --columns ID,Name < sample.csv
| ID | Name |
|----|------|
| 23 | foo  |
| 42 | bar  |
| 99 | doz  |

In Perl scripts πŸ¦‹

use Catmandu::Exporter::Table;
my $exp = Catmandu::Exporter::Table->new;
$exp->add({ title => "The Hobbit", author => "Tolkien" });
$exp->add({ title => "Where the Wild Things Are", author => "Sendak" });
$exp->add({ title => "One Thousand and One Nights" });
$exp->commit;

| author  | title                       |
|---------|-----------------------------|
| Tolkien | The Hobbit                  |
| Sendak  | Where the Wild Things Are   |
|         | One Thousand and One Nights |

like. look at those little pipes. so clean. so aligned. it's giving spreadsheet but make it fashion πŸ’…


🌸 DESCRIPTION 🌸

This Catmandu::Exporter exports your data in tabular form, formatted in MultiMarkdown syntax.

The output is perfect for a lil simple display moment β€” for instance, previewing Excel files right there on the command line. And if you wanna go further and convert to other table formats, like latex, html5, or mediawiki, you bring in Pandoc (http://johnmacfarlane.net/pandoc/) and let it cook:

catmandu convert XLS to Table < sheet.xls | pandoc -t html5

By default, columns are sorted alphabetically by field name. alphabetical. always. don't fight it. πŸ”€


πŸŽ€ CONFIGURATION πŸŽ€

Table output can be controlled with the options fields, columns, widths, and condense β€” all as documented in Text::MarkdownTable.

  • file, fh, encoding, fix β€” these are standard options of Catmandu::Exporter πŸ’–
  • condense β€” write the table in condense format with unaligned columns. (the chaotic option. respect it.)
  • fields β€” field names, as a comma-separated list or an array reference.
  • columns β€” column names, as a comma-separated list or an array reference. By default the field names are used as the column names.
  • header β€” include those header lines. Enabled by default. πŸ‘‘
  • widths β€” column widths, as a comma-separated list or array references. Calculated from all rows by default. Heads up bestie: long cell values can get truncated with this option. 😭
  • schema β€” supply fields and (optionally) columns in a JSON Table Schema (http://dataprotocols.org/json-table-schema/), either as a JSON file or as a hash reference, with the following structure:
{
  "fields: [
    { "name": "field-name-1", "title": "column title 1 (optional)" },
    { "name": "field-name-2", "title": "column title 2 (optional)" },
    ...
  ]
}
ngl the "fields: [ line is missing its closing quote β€” that's literally how it's written in the original page, so I'm keeping it character for character. no cap. πŸ™ˆ

πŸ’œ METHODS πŸ’œ

See Catmandu::Exporter. That's the whole vibe check β€” it's all over there. ✨


πŸ¦„ SEE ALSO πŸ¦„

This module is based on Text::MarkdownTable. πŸŽ€

Similar Catmandu Exporters for tabular data include Catmandu::Exporter::CSV, Catmandu::Exporter::XLS, and Catmandu::Exporter::XLSX. the whole table girlie family, obsessed. πŸ’š


and that's the page, bestie!! this manual is perl v5.36.0, dated 2023-02-11, and it was served up as Catman...::Table(3pm). go make a table, it'll eat, periodt πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from