A library to open DATASUS files (*.dbc) in Python
IMPORTANT: this project is still in an experimental state. Use it at your own risk. Actually, even after it matures, you still will have to use it at your own risk :) (see LICENSE for details)
Since this is a development version you will need to install the package from this repo. Future versions will be published to PyPI as soon as I achieve my goal which is to have a simple function to read DBC files to a Pandas dataframe.
To install it to your system you can use make
:
$ make install
Note: this requires setuptools
to be installed on your system.
from datasus import read_dbc
import pandas as pd
df = pd.DataFrame(read_dbc("my-file.dbc"))
You can decompress a *.dbc file from python importing the decompress
method:
$ python3
>>> from datasus import decompress
>>> decompress("file.dbc", "file.dbf")
>>>
Or you can run the helper script from the command line:
$ dbc2dbf.py input-file.dbc output-file.dbf
For support, kudos and complaints drop me an e-mail at [email protected]. Or Twitter @danicat83, at least until Elon burns the place to the ground.
If you don't like Python and prefer R instead, see my other project read.dbc.