NAME

TableData - Specification for TableData::*, modules that contains table data

SPECIFICATION VERSION

0.2

VERSION

This document describes version 0.2.6 of TableData (from Perl distribution TableData), released on 2023-11-25.

SYNOPSIS

Use one of the TableData::* modules.

DESCRIPTION

NOTE: EARLY SPECIFICATION; THINGS WILL STILL CHANGE A LOT.

TableData::* modules are modules that contain two-dimensional table data. The table can be accessed via a standard interface (see TableDataRole::Spec::Basic). An example of table data would be list of countries along with their names and country code, or a list of CPAN authors along with their published email addresses.

Why put data in a Perl module, as a Perl distribution? To leverage the Perl/CPAN toolchain and infrastructure: 1) ease of installation, update, and uninstallation; 2) allowing dependency expression and version comparison; 3) ease of packaging further as OS packages, e.g. Debian packages (converted from Perl distribution); 4) testing by CPAN Testers.

The table data can actually be stored as CSV in the DATA section of a Perl module, or as a CSV file in a shared directory of a Perl distribution, or a Perl structure in the module source code, or from other sources.

The standard interface provides a convenient and consistent way to access the data, from accessing the rows, getting the column names, and dumping to CSV or Perl structure for other tools to operate on.

To get started, see TableDataRole::Spec::Basic and one of existing TableData::* module.

NAMESPACE ORGANIZATION

TableData

TableData (this module) is the specification.

All the modules under TableData::* are modules with actual table data. The entity mentioned in the module name should be singular, not plural (e.g. TableData::Person::AcmeInc instead of TableData::Persons::AcmeInc or TableData::People::AcmeInc.

More specific subnamespaces for more specific types of table data are described in entries below.

TableData::Calendar::*

For calendar-related data.

TableData::Calendar::Date::*

For table containing calendar dates.

Examples:

TableData::Calendar::Date::Holiday::ID contains holiday dates for Indonesia.

TableData::Calendar::Date::Holiday::AU::TAS contains holiday dates for Tasmania, Australia.

TableData::Lingua::*

For human-language-related data.

TableData::Lingua::Dict::*

For dictionaries.

For monolingual language dictionaries, a 2-letter ISO language code should be added as subnamespace prefix. For bilingual dictionaries, a LANGCODE1_LANGCODE2 should be added as subnamespace prefix.

All TableData::Lingua::Dict::* modules should contain the columns entry and description.

Examples: TableData::Lingua::Dict::Foldoc, TableData::Lingua::Dict::ID::KBBI, TableData::Lingua::Dict::ZH::Proverb::StarDict, TableData::Lingua::Dict::FR_EN::FreeDict.

TableData::Lingua::Word::*

For tables that contain word list. This is now preferred namespace to WordList, and an alternative for ArrayData::Lingua::Word:: namespace.

All TableData::Lingua::Word::* modules should contain the column word so they are usable from applications like word games.

A 2-letter ISO language code should be added as subnamespace prefix whenever applicable.

Example: TableData::Lingua::Word::EN::Adjective::TalkEnglish (list of top adjectives from talkenglish.com website, along with some other data like frequency).

TableData::Locale::*

For locale-related data.

Examples: TableData::Locale::Country (list of countries in the world), TableData::Locale::US::State (list of US states), TableData::Locale::ID::Province (list of Indonesian provinces).

TableDataRole::*

The roles.

TableDataRoles::*

TableDataRoles::* are names for distributions that contains several role modules.

TableDataBase::*

For base classes.

TableDataBases::*

TableDataBases::* are names for distributions that contain several TableDataBase modules.

TableDataBundle::*

TableDataBundle::* are names for distributions that contain several TableData modules. The subnamespaces can follow that of TableData.

Examples: TableDataBundle::Perl::CPAN::Release which contains TableData::Perl::CPAN::Release::Static and TableData::Perl::CPAN::Release::Static::FromNewest. TableDataBundle::Software::License which contains TableData::Software::License::FromRPL and TableData::Software::License::FromSL.

RELATED NAMESPACES

Data::TableData::*

Modules that contain code to work with table data (not necessarily table data in TableData:: modules).

FAQ

How do I pick random row(s) from a table?

Apply one of the appropriate Role::TinyCommons::Collection::PickItems::* roles, e.g. Role::TinyCommons::Collection::PickItems::Iterator (which can always be used, but other role might offer some speedup). This will provide you the pick_item and pick_items methods. For example, to select a random quoute from TableData::Quote::JamesFT:

use Role::Tiny;
use TableData::Quote::JamesFT;

my $td = TableData::Quote::JamesFT->new;
Role::Tiny->apply_roles_to_object($td, 'Role::TinyCommons::Collection::PickItems::Iterator');

my $row = $td->pick_item;

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/TableData.

SOURCE

Source repository is at https://github.com/perlancar/perl-TableData.

SEE ALSO

ArrayData, HashData are related projects.

WordList is an older, related project.

Modules and CLIs that manipulate table data: Data::TableData::Object, td (from App::td).

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2022, 2021, 2020 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=TableData

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.