A Tcl interface to read DBF files

tcldbf is an extension of Tcl/Tk that provides the Tcl script writer some ability to read and write DBF files. Its core is a set of C wrappers that read dBase files using Frank Warmerdam's shapelib and make the results available to Tcl procedures.


tcldbf-1.3.tgz 183K gzipped tar file
tcldbf-1.3.zip 192K zip file


dbf d -open input_file ?-readonly?
opens DBF file, returns the name of a command used for subsequent operations. If readonly is specified, the file cannot be updated.
dbf d -create output_file
creates a DBF file, returns the name of a command used for subsequent operations. Initially the file will have no fields.
$d add label type width ?decimals?
Adds a field an empty DBF file just created. The file cannot have any records.
$d update row field value
Replaces the value of the field on the indicated record.
$d insert row | end value0 ?value1 value2 ...?
$d insert row | end list
Replaces the given record with the values specified. If 'end' is specified as the row, inserts a new record in the file.
$d info
returns a list containing {record_count field_count}
$d fields
returns a list of lists, each of which consists of {name type native-type width prec}
$d values name
returns a list of values of the field named
$d record rowid
returns a list of cell values (as strings) for the given row
$d close
closes the DBF file
$d forget
closes the DBF file


You'll need Tcl/Tk installed on your system in order to make use of this software. You can download Tcl/Tk from ActiveState, the company that currently provides an excellent free distribution:

Assuming you're using Microsoft Windows and you installed ActiveTcl into C:/Tcl, copy the DLL file (at this writing dbf1.2.dll) into the directory C:/Tcl/lib. Then create a directory C:/Tcl/lib/dbf, copy the file pkgIndex.tcl-win into it, and rename the file pkgIndex.tcl. To test, open a command prompt window, type tclsh, then at the % prompt, type package require dbf. The response should be the version number of Tcldbf, at this writing 1.2.

Technical contact:

    Peter N. Schweitzer
    Mail Stop 954, National Center
    U.S. Geological Survey
    Reston, VA 20192

    Tel: (703) 648-6533
    FAX: (703) 648-6252
    Email: pschweitzer@usgs.gov