This python library enables the decompression of *.dbc files commonly found on Brazil's DATASUS FTP server into *.dbf files.
This is a python bindings of the sister library datasus-dbc, written in rust. Because of that, this library should be compatible with most platforms.
pip install datasus-dbc
- To decompress a
*.dbcfile into a*.dbf, use thedecompressfunction:
import datasus_dbc
datasus_dbc.decompress("input.dbc", "output.dbf")- If you have the raw bytes of a
*.dbcfile, you can usedecompress_bytesfunction to obtain the decompressed*.dbfraw bytes in memory:
import datasus_dbc
with open("input.dbc", "rb") as file:
dbf_bytes = datasus_dbc.decompress_bytes(file.read())
print(dbf_bytes)This library does not support reading the contents of a *.dbf file. However, you can still use one of the following libraries: simpledbf or dbfread.
If you encounter a bug or have a feature request, please feel free to create an issue on our GitHub repository. We welcome your feedback!