https://github.com/librecat/catmandu-exporter-table
ASCII/Markdown table exporter for Catmandu
https://github.com/librecat/catmandu-exporter-table
Last synced: 8 months ago
JSON representation
ASCII/Markdown table exporter for Catmandu
- Host: GitHub
- URL: https://github.com/librecat/catmandu-exporter-table
- Owner: LibreCat
- License: other
- Created: 2014-06-14T20:15:55.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-06T07:50:39.000Z (over 10 years ago)
- Last Synced: 2025-01-12T14:36:18.056Z (10 months ago)
- Language: Perl
- Homepage: https://metacpan.org/pod/Catmandu::Exporter::Table
- Size: 195 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Catmandu::Exporter::Table - ASCII/Markdown table exporter
# STATUS
[](https://travis-ci.org/LibreCat/Catmandu-Exporter-Table)
[](https://coveralls.io/r/LibreCat/Catmandu-Exporter-Table)
[](http://cpants.cpanauthors.org/dist/Catmandu-Exporter-Table)
# SYNOPSIS
With [catmandu](https://metacpan.org/pod/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 |
# DESCRIPTION
This [Catmandu::Exporter](https://metacpan.org/pod/Catmandu::Exporter) exports data in tabular form, formatted in
MultiMarkdown syntax.
The output can be used for simple display, for instance to preview Excel files
on the command line. Use [Pandoc](http://johnmacfarlane.net/pandoc/) too
further convert to other table formats, e.g. `latex`, `html5`, `mediawiki`:
catmandu convert XLS to Table < sheet.xls | pandoc -t html5
By default columns are sorted alphabetically by field name.
# CONFIGURATION
- file
- fh
- encoding
- fix
Standard options of [Catmandu:Exporter](Catmandu:Exporter)
- condense
Write table in condense format with unaligned columns.
- fields
Field names as comma-separated list or array reference.
- columns
Column names as comma-separated list or array reference. By default field
names are used as column names.
- header
Include header lines. Enabled by default.
- widths
Column widths as comma-separated list or array references. Calculated from all
rows by default. 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/) as JSON file or hash
reference having the following structure:
{
"fields: [
{ "name": "field-name-1", "title": "column title 1 (optional)" },
{ "name": "field-name-2", "title": "column title 2 (optional)" },
...
]
}
# METHODS
See [Catmandu::Exporter](https://metacpan.org/pod/Catmandu::Exporter)
# SEE ALSO
This module is based on [Text::MarkdownTable](https://metacpan.org/pod/Text::MarkdownTable).
Similar Catmandu Exporters for tabular data include
[Catmandu::Exporter::CSV](https://metacpan.org/pod/Catmandu::Exporter::CSV), [Catmandu::Exporter::XLS](https://metacpan.org/pod/Catmandu::Exporter::XLS), and
[Catmandu::Exporter::XLSX](https://metacpan.org/pod/Catmandu::Exporter::XLSX).
# COPYRIGHT AND LICENSE
Copyright Jakob Voss, 2014-
This is free software; you can redistribute it and/or modify it under the same
terms as the Perl 5 programming language system itself.