Format of a dBase III+ File Philip J. Erdelsky 12-26-2012 This description is restricted to dBase III+ files with no memo fields. The usual extension for the dbase III+ file is .DBF. A dBase III+ file contains structure and data for a single table. When used with SQL, the file name (without the .DBF extension) is usually the table name. Multiple-byte numeric values are stored in little-endian order (least significant byte first). A dBase III+ file begins with a header of variable length: size in bytes contents ------------- ----------------------------------------------- 1 0x03 (to mark the file as version 3) 1 year of most recent update, modulo 100 1 month of most recent update, 1=Jan, 2=Feb, etc. 1 day of month of most recent update 4 number of records 2 number of bytes in header 2 number of bytes per record 20 unused and filled with zeros variable field descriptors 1 0x0D Each field descriptor is exactly 32 bytes long: size in bytes contents ------------- ---------------------------------------------- 11 name, in ASCII characters with nul fill at end 1 type, as ASCII character: "C" for a Character field "N" for a Numeric field "D" for a Date field "L" for a Logical field 4 internal use only (may be filled with zeros) 1 width 1 precision, for Numeric field only 14 unused and filled with zeros The name must be no more than 10 characters long, so it will always be nul-terminated. All letters are uppercase. For a Date field, the width is always 8. For a Logical field, the width is always 1. For a Numeric field, the precision is the number of places to the right of the decimal point. For other kinds of fields, it is zero. For a Numeric field, the width must be positive and no greater than 19. The precision must be either zero or a positive value no greater than 15 and also no greater than two less than the width. These restrictions ensure that the number will fit into its field. The record contents follow the header. Unless the table has been sorted, they will be in the order in which they were added to the table. Each record is precisely the length specified in the header. The first byte of a record is an ASCII asterisk if the record has been marked as deleted, or an ASCII space otherwise. Subsequent bytes of a record contain the field contents, in the order in which the corresponding field descriptors appeared in the header. A Character field is padded at the end with ASCII blanks, if necessary, to make its width equal to the value specified in its field descriptor in the header. A Date field occupies exactly eight bytes, which are the ASCII characters for the date in yyyymmdd format. For example, July 28, 2005 would appear as "20050728". A missing date is represented by eight ASCII spaces. A Numeric field is represented by the ASCII characters for its decimal representation, with a decimal point at the appropriate position if the precision is nonzero, a prefixed minus sign if the number is negative, and enough ASCII spaces at the left end to make the width equal to the value specified in its field descriptor in the header. A missing numeric value is represented by ASCII spaces, but it is interpreted as zero by most dBase software. A Logical field is represented by an ASCII "T" if it is true, or by an ASCII "F" if it is false. There is no other value. An end-of-file control character (0x1A) is placed after the last record to mark the end of the file.