App::CSVUtils - CLI utilities related to CSV
This document describes version 0.002 of App::CSVUtils (from Perl distribution App-CSVUtils), released on 2016-11-02.
This distribution contains the following CLI utilities:
csv-add-field
csv-delete-field
csv-list-field-names
csv-munge-field
csvutil
replace-newline-in-csv
Add a field to CSV file.
This command:
% csv-add-field FILE.CSV FIELDNAME 'perl code'
is equivalent to:
% csvutil add-field FILE.CSV -F FIELDNAME -e 'perl code'
Your Perl code should return the value for the field. $main::row is available and contains the current row, while $main::rownum contains the row number (1 means the header row, 2 means the first data row). Field will be added as the last field.
$main::row
$main::rownum
This function is not exported.
Arguments ('*' denotes required arguments):
eval* => str
Perl code to do munging.
field* => str
Field name.
filename* => filename
Input CSV file.
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.
Return value: (any)
Delete a field from CSV file.
% csv-delete-field FILE.CSV FIELDNAME
% csvutil delete-field FILE.CSV -F FIELDNAME
Field must exist and there must be at least one remaining field after deletion.
List field names of CSV file.
Munge a field in every row of CSV file.
% csv-munge-field FILE.CSV FIELDNAME 'perl code'
% csvutil munge-field FILE.CSV -F FIELDNAME -e 'perl code'
Perl code will be called for each row and $_ will contain the value of the field FIELDNAME, which the Perl code is expected to modify. $main::row will contain the current row array and $main::rownum contains the row number (1 means the header row, 2 means the first data row).
$_
FIELDNAME
Perform action on a CSV file.
action* => str
eval => str
field => str
Please visit the project's homepage at https://metacpan.org/release/App-CSVUtils.
Source repository is at https://github.com/perlancar/perl-App-CSVUtils.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-CSVUtils
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.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by 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.
To install App::CSVUtils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::CSVUtils
CPAN shell
perl -MCPAN -e shell install App::CSVUtils
For more information on module installation, please visit the detailed CPAN module installation guide.