CSVUtils/csv2td.pm

filter: Statementstmt 77.2% 17 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod n/a totaltotal 75.0% 21 / 28 CC 1 SCAR 2.9
CC
1
Cov
77%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« CSVUtils/csv_convert_to_hash.pm ↑ Summary CSVUtils/csv_info.pm »
1 package App::CSVUtils::csv2td;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 1 our $DATE = '2026-07-09'; # DATE
9 1 our $DIST = 'App-CSVUtils'; # DIST
10 1 our $VERSION = '1.038'; # VERSION
11  
12 1 ▶use App::CSVUtils qw(gen_csv_util);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 gen_csv_util(
15 name => 'csv2td',
16 summary => 'Return an enveloped aoaos table data from CSV data',
17 description => <<'MARKDOWN',
18  
19 Read more about "table data" in <pm:App::td>, which comes with a CLI <prog:td>
20 to munge table data.
21  
22 MARKDOWN
23 add_args => {
24 },
25 tags => ['category:converting','outputs-data-structure'],
26  
27 examples => [
28 {
29 summary => 'Convert to table data then use the "td" utility to grab the first 5 rows',
30 src => '[[prog]] file.csv --json | td head -n5',
31 src_plang => 'bash',
32 test => 0,
33 'x.doc.show_result' => 0,
34 },
35 ],
36  
37 0 ▶ on_input_header_row => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 my $r = shift;
39  
40 0 $r->{result} = [200, "OK", [], {'table.fields' => $r->{input_fields}}];
41 },
42  
43 0 ▶ on_input_data_row => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 my $r = shift;
45  
46 0 push @{ $r->{result}[2] }, $r->{input_row};
47 },
48  
49 1 writes_csv => 0,
50 );
51  
52 1 1;
53 # ABSTRACT: Return an enveloped aoaos table data from CSV data
54  
55 __END__
« CSVUtils/csv_convert_to_hash.pm ↑ Summary CSVUtils/csv_info.pm »