DBF Swiss Army Knife

DBF Swiss Army Knife: A tool for converting to and from DBF files.

What Is It?

DBFSAK is a command line program designed to extract data from DBF (dBase, FoxPro, Clipper, xBase) files. It can also be used to create DBF files and populate them from your data. It is written for the Linux/Unix environment, but relies only on standard C libraries and functions. So it will probably run anywhere you have access to a C compiler. The package is distributed as a gzipped (compressed) tar archive of source code files, along with a Makefile and assorted other administrative files.

What Does It Do?

DBFSAK is a command line tool to convert other files into DBF files, and to export data in DBF files into other formats. For example, DBFSAK lets you look at the data in a DBF file-- its header data (record size and anatomy, number of records, etc.) and/or the actual "meat" of the file, the records themselves. You can dump the records in a straight text format with the field delimiter of your choice. You can have the output fields the size they are in the file, or you can trim leading and trailing space from the fields.

You can also dump files out in NoSQL/RDB format. NoSQL files are flat text files. Their first line contains the field names, tab-delimited. A second line contains just a row of dashes for each field, also tab-delimited. The rest of the file is the fields in tab-delimited format. NoSQL is a package which contains a set of command line utilities for storing and manipulating flat files in the NoSQL format. But it's also simple enough to be a good intermediate format for converting other files into and out of.

Since I also work a lot with SQL files, DBFSAK also offers the ability to dump DBF files into SQL formats in four ways. First, DBFSAK can dump files in PostgreSQL Copy format. This format is a flat file format similar to NoSQL format, and is used with the PostgreSQL COPY command. DBFSAK can also dump DBF records in PostgreSQL INSERT format. This represents the records in the form of a PostgreSQL INSERT command. Similarly, DBFSAK will dump records in MySQL COPY and INSERT formats.

How Is This Code Licensed?

DBFSAK is released under the Artistic License. This means you're welcome to do almost anything with the code. You may even include it in commercial products.

Why Did I Write This?

I use DBF files all the time, because my company does "bulk" mailings (U.S.) for our customers. The software we use to check our customers' lists uses DBF files natively. So we have to convert whatever our customers give us into DBF format files. In addition, much of the early code I wrote to run my company was written in FoxPro 2.6 for DOS. At some point, I needed to convert all that data into PostgreSQL and rewrite the applications in PHP. So DBFSAK was instrumental in doing the data conversion. There is another much older program which does some similar things called dbview. However, it's not maintained, it doesn't have all the features I want, and it appears to behave inconsistently.

So I set about to code a replacement to do what I want. It has been through quite a few iterations, being coded originally in C, then C++ and then back to C again.

Who Wrote This Code/Can I Contribute?

I (Paul M. Foster) wrote the vast majority of the original code. There have been some modifications (such as the MySQL code) which have been contributed by others. You're also welcome to contribute code. However, be aware that, since it's my package, I reserve the right to include or not include your code. And although I'll be glad to give you full credit for the code, it will be copyrighted by me.

What If I Find A Bug?

How DARE you! Seriously, if you find a bug, would like to contribute code, or have other questions about this package, you may contact me at paulmfoster at users dot sourceforge dot net.