Skip to main content

Module dbf

Module dbf 

Source
Expand description

dBASE III+/IV table reader for .dbf attribute sidecars.

§Layout (header)

BytesField
0Version flags
1..4Last-update YY MM DD
4..8Number of records (u32 LE)
8..10Header length in bytes (u16 LE)
10..12Record length in bytes (u16 LE)
29Language Driver ID (codepage hint)

Then (header_length - 32 - 1) / 32 field descriptors of 32 bytes each, terminated by 0x0D. Each record starts with a 1-byte deletion flag (0x20 active, 0x2A deleted) and is followed by fixed-width field values.

§v0.1 field type coverage

  • C Character — UTF-8/ASCII trimmed, → Value::String
  • N Numeric (ASCII digits) — parsed to Value::Int64 if no decimals, else Value::Float64
  • F Float (ASCII) — Value::Float64
  • D Date (YYYYMMDD) — Value::DateTime (days since 1899-12-30)
  • L Logical (T/F/Y/N/?) — Value::Bool, blank or ?Value::Null
  • Anything else (M memo, B, G, OLE, …) → Value::Null

§Encoding

v0.1 assumes ASCII / UTF-8 input. Real .cpg / LDID handling is deferred to v0.2 — until then non-UTF-8 strings come through with invalid bytes replaced.

Structs§

DbfField
DbfHeader

Functions§

build_schema
Build a Schema from the DBF header + a geometry-column descriptor for the companion .shp.
decode_field
Decode the value of a single field within a record. record_bytes includes the 1-byte deletion flag at index 0.
field_to_def
Map a DBF field to a core FieldDef.
parse_header