utility methods for best-effort datatype casting
[migration-tools.git] / csv_ripper
index bf787ff..8ae35e9 100755 (executable)
@@ -14,15 +14,16 @@ use warnings;
 
 use Text::CSV;
 
-my $csv = Text::CSV->new();
+my $csv = Text::CSV->new( {binary => 1});
 
 open CSV, '<', shift or die "Can't open file $!\n";
 
 while (<CSV>) {
     $csv->parse($_);
+    die "Bad data on line $.\n$_\n" if ($csv->error_diag);
     my @chunks = $csv->fields;
     my @out = ();
-    for (@ARGV)
-      { push @out, $chunks[$_]}
+    for my $chunk (@ARGV)
+      { push @out, $chunks[$chunk] }
     print join("\t", @out), "\n";
 }