Skip to content

Instantly share code, notes, and snippets.

@Tux
Created March 6, 2015 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tux/f781bdefeb190e12a265 to your computer and use it in GitHub Desktop.
Save Tux/f781bdefeb190e12a265 to your computer and use it in GitHub Desktop.
sh$ for i in $(seq 1 1000000); do echo 'hello,","," ",world,"!"'; done > /tmp/hello.csv
sh$ cat cat csv-ip5xs.pl
#!perl6
use v6;
use Slang::Tuxic;
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.use ("Text::CSV_XS");
my @rows;
my $csv = $p5.invoke ("Text::CSV_XS", "new")
or die "Cannot use CSV: ", $p5.invoke ("Text::CSV_XS", "error_diag");
$csv.binary (1);
$csv.auto_diag (1);
my Int $sum = 0;
for lines () :eager {
$csv.parse ($_);
$sum += $csv.fields.elems;
}
$sum.say;
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment