Skip to main content

dbfread - Read DBF Files with Python

DBF is a file format used by databases such dBase, Visual FoxPro, and FoxBase+. This library reads DBF files and returns the data as native Python data types for further processing. It is primarily intended for batch jobs and one-off scripts.

>>> from dbfread import DBF
>>> for record in DBF('people.dbf'):
...     print(record)
OrderedDict([('NAME', 'Alice'), ('BIRTHDATE', datetime.date(1987, 3, 1))])
OrderedDict([('NAME', 'Bob'), ('BIRTHDATE', datetime.date(1980, 11, 12))])

By default records are streamed directly from the file. If you have enough memory you can instead load them into a list. This allows for random access:

>>> table = DBF('people.dbf', load=True)
>>> print(table.records[1]['NAME'])
Bob
>>> print(table.records[0]['NAME'])
Alice

Full documentation at https://dbfread.readthedocs.io/

See docs/changes.rst for a full list of changes in each version.

Main Features

  • written for Python 3, but also works in 2.7

  • simple but flexible API

  • data is returned as native Python data types

  • records are ordered dictionaries, but can be reconfigured to be of any type

  • aims to handle all variants of DBF files. (Currently only widely tested with Visual FoxPro, but should work well with other variants.)

  • support for 18 field types. Custom types can be added by subclassing FieldParser

  • reads FPT and DBT memo files, both text and binary data

  • handles mixed case file names gracefully on case sensitive file systems

  • can retrieve deleted records

Installing

Requires Python 3.2 or 2.7.

pip install dbfread

dbfread is a pure Python module and doesn’t depend on any packages outside the standard library.

To build documentation locally:

python setup.py docs

This requires Sphinx. The resulting files can be found in docs/_build/.

Source code

Latest stable release: http://github.com/olemb/dbfread/

Development version: http://github.com/olemb/dbfread/tree/develop/

API Changes

dbfread.open() and dbfread.read() are deprecated as of version 2.0, and will be removed in 2.2.

The DBF class is no longer a subclass of list. This makes the API a lot cleaner and easier to understand, but old code that relied on this behaviour will be broken. Iteration and record counting works the same as before. Other list operations can be rewritten using the record attribute. For example:

table = dbfread.read('people.dbf')
print(table[1])

can be rewritten as:

table = DBF('people.dbf', load=True)
print(table.records[1])

open() and read() both return DeprecatedDBF, which is a subclass of DBF and list and thus backward compatible.

License

dbfread is released under the terms of the MIT license.

Contact

Ole Martin Bjorndalen - ombdalen@gmail.com

Metadata

Release files for dbfread 2.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbfread 2.0.7
File Size Uploaded
dbfread-2.0.7.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbfread 2.0.7
File Interpreter ABI Platform
dbfread-2.0.7-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 53.2 kB

Release files / dbfread-2.0.7.tar.gz

Download URL dbfread-2.0.7.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
07c8a9af06ffad3f6f03e8fe91ad7d2733e31a26d2b72c4dd4cfbae07ee3b73d
BLAKE2b-256 checksum
How to use checksums
adaea5891681f5012724d062a4ca63ec2ff539c73d5804ba594e7e0e72099d3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dbfread-2.0.7-py2.py3-none-any.whl

Download URL dbfread-2.0.7-py2.py3-none-any.whl
Size 20.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f604def58c59694fa0160d7be5d0b8d594467278d2bb6a47d46daf7162c84cec
BLAKE2b-256 checksum
How to use checksums
4c9451349e43503e30ed7b4ecfe68a8809cdb58f722c0feb79d18b1f1e36fe74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0.7 This release

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.1

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page