Text 21 Dec Converting DBF to CSV files

How to convert DBF to CSV files:

1) Install PERL, DBI, and DBD::XBase (comes as a package for many Linux distributions). 2) Use a script like this one:

#!/usr/bin/perl
use DBI;

my $dbh = DBI->connect("DBI:XBase:/directory/of/dbf/file") or die;
my $sth = $dbh->prepare("select * from YourDbfNameWithoutFileExtension") or die;
$sth->execute() or die $sth->errstr();

# adapt column names
print "Col1Name,Col2Name,Col3Name\n";

my @data;
while (my @data = $sth->fetchrow_array()) {
    print join(",",@data)."\n";
}

3) Call this script and redirect stdout to the CSV file.


Design crafted by Prashanth Kamalakanthan. Powered by Tumblr.