X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=csv_ripper;fp=csv_ripper;h=99e047cd145323a626b5af9225c65a9dbe4bb744;hp=0000000000000000000000000000000000000000;hb=86a6483dcbc8afc774e3e666f360ea940cd6b0d3;hpb=e18d073890076b6a9c6963074eb3be520aebaa75 diff --git a/csv_ripper b/csv_ripper new file mode 100755 index 0000000..99e047c --- /dev/null +++ b/csv_ripper @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +# TODO +# +# * add getopt support +# * use tag generator to expand list of wanted fields? +# * insertion of constant-value fields +# * field mapping ("some text" -> 4)? + +# csv-extractor FILENAME FIELD_LIST + +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"; +}