9

I need to open dbf files on my Ubuntu 15 and as I found LibreOffice can does this. But I'm getting

General Error. General input/output error.

Is there ANY tool or built-in some software tool that can help me?

  • We do not care if it opens on Windows. – Rinzwind Oct 20 '15 at 7:09
  • 1
    @Rinzwind Yeah, and that's will make me answering such questions as "Did you try to open it in some other system/software?" – Daria Oct 20 '15 at 7:11
  • Even if that is a valid question it will be Ubuntu only. And we do not expect a user to have Windows installed ;-) – Rinzwind Oct 20 '15 at 7:20
  • 4
    @Rinzwind It actually shows that the file is (likely) valid. – Cthulhu Oct 20 '15 at 9:14
11

According to the LibreOffice Wiki you should be able to open .dbf files with LibreOffice Base.

If you still encounter this problem, reinstall LibreOffice:

sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get install libreoffice

You can also use dbview to open .dbf files (which may be harder to use than LibreOffice Base):

sudo apt-get install dbview

Refer to the manpage for more information on dbview.

  • 1
    Great! I guess I didn't have LibreOffice Base and reinstallation bring it) Also dbview is a good console (as I got it right) app that can make preview dbf file easily. Thank you. – Daria Oct 20 '15 at 7:23
  • 2
    As LibreOffice Base is not installed by default in Ubuntu, you might want to start by checking that it actually is. – leo Dec 21 '16 at 12:17
2

I have found the best way to deal with .dbf files is to use PHP to convert them to .csv files:

<?php

set_time_limit( 24192000 );
ini_set( 'memory_limit', '-1' );

$files = glob( '/media/d/Data2/files/*.DBF' );
foreach( $files as $file )
{
    echo "Processing: $file\n";
    $fileParts = explode( '/', $file );
    $endPart = $fileParts[key( array_slice( $fileParts, -1, 1, true ) )];
    $csvFile = preg_replace( '~\.[a-z]+$~i', '.csv', $endPart );

    if( !$dbf = dbase_open( $file, 0 ) ) die( "Could not connect to: $file" );
    $num_rec = dbase_numrecords( $dbf );
    $num_fields = dbase_numfields( $dbf );

    $fields = array();
    $out = '';

    for( $i = 1; $i <= $num_rec; $i++ )
    {
        $row = @dbase_get_record_with_names( $dbf, $i );
        $firstKey = key( array_slice( $row, 0, 1, true ) );
        foreach( $row as $key => $val )
        {
            if( $key == 'deleted' ) continue;
            if( $firstKey != $key ) $out .= ';';
            $out .= trim( $val );
        }
        $out .= "\n";
    }

    file_put_contents( $csvFile, $out );
}

?>

Then use MySQL to import the CSV:

LOAD DATA INFILE "/media/d/Data2/files/ZACATECAS.csv" INTO TABLE tbl FIELDS TERMINATED BY ";" ENCLOSED BY '"' LINES TERMINATED BY "\n";
2

For very simple editing of small .dbf files, you can also use GTK DBF Editor

To install it in Ubuntu 12.04, I first needed to install this dependency:

sudo apt-get install libglade2-0:i386

Then I could install the downloaded .deb file with

sudo dpkg -i Downloads/gtkdbfeditor_1.0.4-7_i386.deb

Update:

In Ubuntu 16.04, with the default install of LibreOffice, I had to also

sudo apt install libreoffice-base

Then, .dbf files can be opened in LibreOffice Calc, and also saved as .dbf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.