Acme::CPANModules::WorkingWithCSV - Working with CSV (comma-separated value) data in Perl
This document describes version 0.001 of Acme::CPANModules::WorkingWithCSV (from Perl distribution Acme-CPANModules-WorkingWithCSV), released on 2022-07-27.
The following are tools (modules and scripts) to work with the CSV format:
Parsing
First things first, the most important module to work with CSV in Perl is Text::CSV (which will use Text::CSV_XS backend when possible but fall back to Text::CSV_PP otherwise). It's not in core, but only a cpanm command away.
Generating CSV from Perl array/structure
Text::CSV (as well as Text::CSV_XS) can render a line of CSV from Perl array(ref) with their say() method.
say()
dd2csv from App::CSVUtils
Perinci::CmdLine framework can render function result (CLI output) as CSV.
Converting to/from other formats
INI: ini2csv from App::TextTableUtils
TSV: csv2tsv and Ltsv2csv from App::CSVUtils
LTSV: csv2ltsv from App::CSVUtils and Lltsv2csv from App::LTSVUtils
XLS and XLSX: csv2tsv and tsv2csv from App::CSVUtils
JSON: csv2json and json2csv from App::TextTableUtils
Markdown table: csv2mdtable from App::TextTableUtils
Org table: csv2orgtable from App::TextTableUtils
SQLite database: csv2sqlite from App::SQLiteUtils
Rendering as text/ASCII table
csv2texttable from App::TextTableUtils
Changing field separator character, field quote character, and/or escape character
csv-csv from App::CSVUtils
Adding/removing columns
csv-add-field, csv-delete-field, csv-select-fields from App::CSVUtils
Processing columns of CSV with Perl code
csv-munge-field from App::CSVUtils
Processing rows of CSV with Perl code
Aside from the obvious Text::CSV, you can also use csv-each-row, csv-munge-row, csv-mp from App::CSVUtils.
Merging several CSV files into one
csv-concat from App::CSVUtils
Splitting a CSV file into several
csv-split from App::CSVUtils
Sorting CSV rows
csv-sort from App::CSVUtils
Sorting CSV columns
csv-sort-fields from App::CSVUtils
Filtering CSV columns
csv-select-fields from App::CSVUtils
Filtering CSV rows
csv-grep and csv-select-rows from App::CSVUtils
csvgrep from csvgrep
Transposing CSV
csv-transpose from App::CSVUtils
Summing and averaging rows
csv-sum and csv-avg from App::CSVUtils
Producing frequency table from CSV
csv-freqtable from App::CSVUtils
Performing set operations (intersection, union, difference) on CSV
csv-setop from App::CSVUtils
Text::CSV - comma-separated values manipulator (using XS or PurePerl)
Author: ISHIGAKI
Text::CSV_XS - comma-separated values manipulation routines
Author: HMBRAND
Text::CSV_PP - Text::CSV_XS compatible pure-Perl module
App::CSVUtils - CLI utilities related to CSV
Author: PERLANCAR
Perinci::CmdLine - Rinci/Riap-based command-line application framework
App::TextTableUtils
App::LTSVUtils - CLI utilities related to LTSV
App::SQLiteUtils - Utilities related to SQLite
csvgrep
Author: NEILB
An Acme::CPANModules::* module, like this module, contains just a list of module names that share a common characteristics. It is a way to categorize modules and document CPAN. See Acme::CPANModules for more details.
Aside from reading this Acme::CPANModules module's POD documentation, you can install all the listed modules (entries) using cpanm-cpanmodules script (from App::cpanm::cpanmodules distribution):
% cpanm-cpanmodules -n WorkingWithCSV
Alternatively you can use the cpanmodules CLI (from App::cpanmodules distribution):
% cpanmodules ls-entries WorkingWithCSV | cpanm -n
or Acme::CM::Get:
% perl -MAcme::CM::Get=WorkingWithCSV -E'say $_->{module} for @{ $LIST->{entries} }' | cpanm -n
or directly:
% perl -MAcme::CPANModules::WorkingWithCSV -E'say $_->{module} for @{ $Acme::CPANModules::WorkingWithCSV::LIST->{entries} }' | cpanm -n
This Acme::CPANModules module also helps lcpan produce a more meaningful result for lcpan related-mods command when it comes to finding related modules for the modules listed in this Acme::CPANModules module. See App::lcpan::Cmd::related_mods for more details on how "related modules" are found.
lcpan related-mods
Please visit the project's homepage at https://metacpan.org/release/Acme-CPANModules-WorkingWithCSV.
Source repository is at https://github.com/perlancar/perl-Acme-CPANModules-WorkingWithCSV.
App::CSVUtils::Manual::Cookbook
The See Also section in App::CSVUtils documentation
Acme::CPANModules - about the Acme::CPANModules namespace
cpanmodules - CLI tool to let you browse/view the lists
perlancar <perlancar@cpan.org>
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, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2022 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.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Acme-CPANModules-WorkingWithCSV
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.
To install Acme::CPANModules::WorkingWithCSV, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::CPANModules::WorkingWithCSV
CPAN shell
perl -MCPAN -e shell install Acme::CPANModules::WorkingWithCSV
For more information on module installation, please visit the detailed CPAN module installation guide.