dbfread is a pure Python library designed to read DBF files (used by databases like dBase, Visual FoxPro, and FoxBase+). It processes the data and returns it as native Python data types, making it ideal for batch jobs and one-off scripts. The current version is 2.0.7, and while stable, it is not actively developed, with its last update being in late 2016.
pip install dbfreadVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a DBF file and iterate through its records. It also shows how to load all records into memory if random access by index is required. It assumes a 'people.dbf' file exists for demonstration.
Always instantiate the `DBF` class directly (e.g., `table = DBF('filename.dbf')`). For list-like access, pass `load=True` to the `DBF` constructor, then access records via `table.records[index]` (e.g., `DBF('filename.dbf', load=True).records[0]`).If character encoding issues arise, explicitly specify the correct encoding using the `encoding` parameter in the `DBF` constructor (e.g., `DBF('file.dbf', encoding='cp1252')`). Common encodings include 'latin1', 'cp1252', or 'utf-8'.To handle missing memo files, pass `ignore_missing_memofile=True` to the `DBF` constructor to suppress `MissingMemoFile` exceptions. If case sensitivity is an issue, consider passing `ignorecase=False` if you know the exact casing of your memo file.
Use the `lowernames=True` parameter in the `DBF` constructor to automatically convert all field names to lowercase, allowing access like `record['fieldname']` instead of `record['FIELDNAME']`.
pip install dbfread
from dbfread import DBF; table = DBF('your_file.dbf', encoding='latin1') # Try different encodings like 'cp1252', 'cp850', 'utf-8' if 'latin1' doesn't work.from dbfread import DBF; table = DBF('correct/absolute/or/relative/path/to/your_file.dbf')from dbfread import DBF; table = DBF('your_file.dbf', ignore_missing_memofile=True) # or ensure the correct memo file is in the same directory as the .dbf file.No dependency data recorded yet.