From: Shawn Boyette Date: Tue, 20 Jan 2009 21:22:29 +0000 (+0000) Subject: first checkin X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=ee8e4e6a9b047dbf7c15b24bb32051b74a4fc2cc first checkin --- diff --git a/csv_extractor b/csv_extractor new file mode 100755 index 0000000..b1c2a2e --- /dev/null +++ b/csv_extractor @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +# TODO +# +# * add getopt support +# * use tag generator to expand list of wanted fields? + +use strict; +use warnings; + +use Text::CSV; + +my $csv = Text::CSV->new({escape_char => "+", allow_loose_quotes => 1}); + +open CSV, '<', shift or die "Can't open file $!\n"; + +while () { + $csv->parse($_); + my @chunks = $csv->fields; + my @out = (); + for (@ARGV) + { push @out, $chunks[$_]} + print join("\t", @out), "\n"; +}