Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A parser for CSV (comma-separated values) files for Perl 6
branch: master

This branch is 1 commit ahead, 19 commits behind masak:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Text
t
LICENSE
META.info
README
TODO

README

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.