Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 35 lines (23 sloc) 1.329 kb
e1759ab @masak [README] clarification
authored
1 Simple CSV (comma-separated values) format parser for Perl 6.
eb19806 @masak initial commit
authored
2
3 use v6;
3e71665 @masak trimming of spaces is now an option
authored
4 use Text::CSV;
eb19806 @masak initial commit
authored
5
ebbec80 @masak s:g/read/parse/ for the Text::CSV methods
authored
6 say Text::CSV.parse-file('somefile.csv').perl;
7 say Text::CSV.parse("foo,bar\nbaz,boo").perl;
3e71665 @masak trimming of spaces is now an option
authored
8
ebbec80 @masak s:g/read/parse/ for the Text::CSV methods
authored
9 Oh, and the C<parse> methods take the following named parameters:
3e71665 @masak trimming of spaces is now an option
authored
10
1e15984 @masak added :skip-header handling
authored
11 :trim Removes whitespace on both ends of each value.
c15254f @masak AoH output now works
authored
12
1e15984 @masak added :skip-header handling
authored
13 :skip-header Causes the first line not to be included in the output.
14
1a672bb @masak introduced :strict, checking columns
authored
15 :strict Throws an error if a row has a different number of columns
16 than the previous ones.
17
1e15984 @masak added :skip-header handling
authored
18 :output Determines the shape of the returned data structure.
59c43db @masak now supports outputting an array of objects
authored
19 Allowed values are 'arrays' (the default), 'hashes',
20 and any type object (i.e. ':output(MyType)').
21 When the value is 'hashes' or a type object, the first line
22 is assumed to be a special header line, the values on that
1e15984 @masak added :skip-header handling
authored
23 line are used as hash keys, and :skip-header is suppressed.
eb19806 @masak initial commit
authored
24
a85e75f @masak added class-level overridable defaults
authored
25 If you see yourself regularly contravening the defaults of one or more of
26 these parameters, it might be a good idea to instantiate the Text::CSV
27 class, giving it the default values you want:
28
ebbec80 @masak s:g/read/parse/ for the Text::CSV methods
authored
29 my $parser = Text::CSV.new( :output<hashes>, :!strict );
30 my Hash[Str] @hashes = $parser.parse-file('somefile.csv');
a85e75f @masak added class-level overridable defaults
authored
31
eb19806 @masak initial commit
authored
32 == License
33
34 This module is released under Artistic 2.0. See LICENSE.
Something went wrong with that request. Please try again.