Stream or load records into memory
masterBy default, dbfread streams records directly from disk, meaning only one record is in memory at a time. This is memory-efficient for large files.
If you need random access to records, you can load them into memory using the load=True argument. This populates the .records attribute with a list of records. You can also load records later by calling .load() on an existing DBF object. To free up memory, use .unload().
If you only need a simple list of records without the table metadata, you can cast the DBF object to a list.
from dbfread import DBF
# 1. Streaming (Default): Memory efficient, one record at a time
table = DBF('people.dbf')
for record in table:
pass
# 2. Loading into memory: Allows random access via table.records
table = DBF('people.dbf', load=True)
print(table.records[1]['NAME'])
# 3. Manual loading: Useful for inspecting headers before loading
table = DBF('people.dbf')
# ... do something with table header ...
table.load()
# 4. Unloading: Free memory
table.unload()
# 5. Quick list conversion
records = list(DBF('people.dbf'))