projects
/
migration-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
3ec4fd7
)
first checkin
author
Shawn Boyette
<sboyette@esilibrary.com>
Tue, 20 Jan 2009 21:22:29 +0000 (21:22 +0000)
committer
Shawn Boyette
<sboyette@esilibrary.com>
Tue, 20 Jan 2009 21:22:29 +0000 (21:22 +0000)
csv_extractor
[new file with mode: 0755]
patch
|
blob
diff --git a/csv_extractor
b/csv_extractor
new file mode 100755
(executable)
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>) {
+ $csv->parse($_);
+ my @chunks = $csv->fields;
+ my @out = ();
+ for (@ARGV)
+ { push @out, $chunks[$_]}
+ print join("\t", @out), "\n";
+}