6 use XBase; # or could use DBI and DBD::XBase;
14 GetOptions('in=s' => \$in, 'out=s' => \$out, 'help' => \$help);
16 if ($help) { &show_help; }
19 if ($in eq '') { push @errors, 'Input file must be specified ( --in inputfile.dbf )' };
20 if ($out eq '') { push @errors, 'Output file must be specified ( --out outputfile.tsv )' };
21 if (@errors > 0) { &show_help (@errors); }
23 open OUT, ">$out" or die $!;
25 my $table = new XBase $in or die XBase->errstr;
27 # get list of field names
28 my @names = $table->field_names;
30 # dump PATRONID, SURNAME, FIRSTNAME
31 print OUT join ("\t", @names) . "\n";
39 Encode::encode("utf8", $_)
40 } else { ''; } # to avoid 'Use of uninitialized value in join'
44 for (0 .. $table->last_record) {
46 my ($deleted, @row) = $table->get_record($_);
47 @row = map (&clean, @row);
48 print OUT join("\t", @row) . "\n" unless $deleted;
52 print STDERR "$i records exported to $out.\n";
57 print "\nERROR - $msg\n" if $msg;
60 dbf2tsv - convert XBase DBF to tab-separated format
64 * Escapes backslash, newline, carriage return, and tab characters.
69 dbf2tsv --in inputfile.dbf --out outputfile.tsv
79 dbf2tsv - convert XBase DBF to tab-separated values
83 dbf2tsv --in inputfile.dbf --out outputfile.dbf
87 Munges data in the following ways:
89 * Escapes backslash, newline, carriage return, and tab characters.