This program creates a DBF output table by joining records with matching keys from a data table to a main table. Every record from the main table is copied to the output table. If a record with the same key exists in the data table, that data record is appended to the corresponding output record. If the data table does not contain a match, null values are appended instead.
If the format of the main table is “
MAINKEY, VAL” and the format of the data table is “
DATAKEY, DATA”, the format of the output table will be “
MAINKEY, VAL, DATA”.
If multiple data records have the same key, only the first record will be used. If multiple main records have the same key, each will appear in the output followed by the same values from the data table, if any.
Only string, integer, and double (floating-point number) field types are supported.
dbfjoin, state the names of the key fields from the main and data tables, followed by the paths to the respective input tables and lastly the path to the output table.
dbfjoin MAINKEY DATAKEY main.dbf data.dbf output.dbf
- Shapelib provides an attribute table API to read and write DBF files.
- Christopher Clark’s C Hash Table code helps locate data table records.
- Dan Bernstein’s djb2 hash function powers the hash table.
dbfjoin, you will need to edit the makefile to locate your copy of Shapelib.