3 # Copyright 2009-2012, Equinox Software, Inc.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # * add getopt support
22 # * use tag generator to expand list of wanted fields?
23 # * insertion of constant-value fields
24 # * field mapping ("some text" -> 4)?
26 # csv-extractor FILENAME FIELD_LIST
33 my $csv = Text::CSV->new( {binary => 1});
35 open CSV, '<', shift or die "Can't open file $!\n";
39 die "Bad data on line $.\n$_\n" if ($csv->error_diag);
40 my @chunks = $csv->fields;
43 { push @out, $chunks[$chunk] }
44 print join("\t", @out), "\n";