-
-
24 May 2021 11:36:26 UTC
- Distribution: FunctionalPerl
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (100 / 2 / 13)
- Kwalitee
Bus factor: 1- License: perl_5
- Perl: v5.16.4
- Activity
24 month- Tools
- Download (443.46KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Christian Jaeger
- Dependencies
- Digest
- File::Path
- Getopt::Long
- Import::Into
- Math::BigInt
- NEXT
- PerlIO::utf8_strict
- Safe::Isa
- Scalar::Util
- Symbol
- Test::More
- autobox
- base
- overload
- utf8
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
FP::Text::CSV - functional interface to Text::CSV
SYNOPSIS
use FP::Text::CSV qw(csv_line_xparser csv_fh_to_rows csv_file_to_rows rows_to_csv_fh rows_to_csv_file); my $csvparams = +{sep_char => ";", eol => "\n"}; # $csvparams and any of its entries are optional, # for the defaults see the Text::CSV docs. use Chj::xopen qw(xopen_read xopen_write); use FP::List; use FP::Stream; use FP::Equal 'is_equal'; mkdir ".tmp"; # -- Output: --- my $rows = cons [ "i", "i^2" ], stream_iota->map(sub { my ($i) = @_; [ $i, $i*$i ] })->take(100); rows_to_csv_fh (Keep($rows), xopen_write(".tmp/a1.csv"), $csvparams); # or rows_to_csv_file ($rows, ".tmp/a2.csv", $csvparams); # -- Input: --- my $p = csv_line_xparser $csvparams; my @vals = &$p("1;2;3;4\n"); is_equal \@vals, [1,2,3,4]; my $itemstream1 = csv_fh_to_rows(xopen_read(".tmp/a1.csv"), $csvparams); # or my $itemstream2 = csv_file_to_rows(".tmp/a2.csv", $csvparams); is_equal $itemstream1, $itemstream2; is_equal $itemstream2->first, [ "i", "i^2" ]; is_equal $itemstream2->second, [ 0, 0 ]; is_equal $itemstream2->ref(10), [ 9, 81 ];
DESCRIPTION
Handle CSV input and output in the form of functional streams (lazily computed linked lists).
NOTE
Text::CSV added a 'csv' export somewhat recently. Together with FP::autobox that can make for a nice solution (although not lazy), too.
This is alpha software! Read the status section in the package README or on the website.
Module Install Instructions
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm FunctionalPerl
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.