Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9b731b3b1f
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 35 lines (23 sloc) 1.329 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Simple CSV (comma-separated values) format parser for Perl 6.

  use v6;
  use Text::CSV;

  say Text::CSV.parse-file('somefile.csv').perl;
  say Text::CSV.parse("foo,bar\nbaz,boo").perl;

Oh, and the C<parse> methods take the following named parameters:

    :trim Removes whitespace on both ends of each value.

    :skip-header Causes the first line not to be included in the output.

    :strict Throws an error if a row has a different number of columns
                 than the previous ones.

    :output Determines the shape of the returned data structure.
                 Allowed values are 'arrays' (the default), 'hashes',
                 and any type object (i.e. ':output(MyType)').
                 When the value is 'hashes' or a type object, the first line
                 is assumed to be a special header line, the values on that
                 line are used as hash keys, and :skip-header is suppressed.

If you see yourself regularly contravening the defaults of one or more of
these parameters, it might be a good idea to instantiate the Text::CSV
class, giving it the default values you want:

  my $parser = Text::CSV.new( :output<hashes>, :!strict );
  my Hash[Str] @hashes = $parser.parse-file('somefile.csv');

== License

This module is released under Artistic 2.0. See LICENSE.
Something went wrong with that request. Please try again.