App-CSV2LaTeXTable
view release on metacpan or search on metacpan
bin/csv2latextable view on Meta::CPAN
#!/usr/bin/env perl
# PODNAME: csv2latextable
use v5.22;
use strict;
use warnings;
our $VERSION = '1.1.0'; # VERSION
use App::CSV2LaTeXTable;
use Getopt::Long;
my %opts;
GetOptions(
'csv=s' => \$opts{csv},
'csv-param=s@' => \$opts{csv_param},
'latex=s' => \$opts{latex},
'latex-param=s@' => \$opts{latex_param},
'split=i' => \$opts{split},
'rotate' => \$opts{rotate},
'help' => \my $help,
);
usage() if $help;
if ( !$opts{csv} || !$opts{latex} ) {
say 'Need csv and latex parameters!';
usage();
}
if ( !-f $opts{csv} ) {
say "file $opts{csv} does not exist";
usage();
}
for my $key ( qw/csv_param latex_param/ ) {
delete $opts{$key} if !defined $opts{$key};
}
$opts{rotate} = 90 if $opts{rotate};
my $app = App::CSV2LaTeXTable->new( %opts ) // usage();
$app->run;
sub usage {
print qq~$0 --csv /path/to/file.csv --latex /path/to/table.tex
--help Display this help.
--csv <filename> A CSV file
--csv-param <key=value> A key value pair for Text::CSV_XS, can be used several times
--latex <filename> The latex file will be created.
--latex-param <key=value> A key-value pair for LaTeX::Table, can be used several times
--split <int> Split the table with <int> rows max per table
--rotate Rotate the table
~;
}
__END__
=pod
=encoding UTF-8
=head1 NAME
csv2latextable
=head1 VERSION
version 1.1.0
=head1 USAGE
=head2 Display usage
$ csv2latextable --help
=head2 Convert CSV file to LaTeX table
$ csv2latextable --csv /path/to/file.csv --latex /path/to/table.tex
=head2 Pass some parameters to Text::CSV_XS
L<Text::CSV_XS> is used to parse the csv.
csv2latextable --csv /path/to/file.csv --csv-param "sep_char=;" --csv-param 'quote_char="' --latex /path/to/table.tex
=head2 Pass some parameters to LaTeX::Table
L<LaTeX::Table> is used to generate the tale.
csv2latextable --csv /path/to/file.csv --csv-param "sep_char=;" --csv-param 'quote_char="' --latex /path/to/table.tex
( run in 2.025 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )