Skip to main content

pyreaddbc package

Project description

pyreaddbc

pyreaddbc is a Python library for working with DBase database file. Legacy systems from the Brazilian Ministry of Health still uses DBF and DBC formats to Publicize data. This package was developed to help PySUS to extract data from these formats into more modern ones. Pyreaddbc can also be used to convert DBC files from any other source."

Installation

You can install pyreaddbc using pip:

pip install pyreaddbc

Usage

Note: Extracting the DBF from a DBC may require to specify the encoding of the original data, if known.

Reading DBC Files

To read a DBC file and convert it to a pandas DataFrame, use the read_dbc function:

import pyreaddbc

dfs = pyreaddbc.read_dbc("LTPI2201.dbc", encoding="iso-8859-1")

Exporting to CSV.GZ

To export a DataFrame to a compressed CSV file (CSV.GZ), you can use pandas:

import pyreaddbc

df = pyreaddbc.read_dbc("./LTPI2201.dbc", encoding="iso-8859-1")
df.to_csv("LTPI2201.csv.gz", compression="gzip", index=False)

Exporting to Parquet

To export a DataFrame to a Parquet file, you can use the pyarrow library:

import pyreaddbc
import pyarrow.parquet as pq
import pandas as pd
from pathlib import Path

# Read DBC file and convert to DataFrame
df = pyreaddbc.read_dbc("./LTPI2201.dbc", encoding="iso-8859-1")

# Export to CSV.GZ
df.to_csv("LTPI2201.csv.gz", compression="gzip", index=False)

# Export to Parquet
pq.write_table(pa.Table.from_pandas(df), "parquets/LTPI2201.parquet")

# Read the Parquet files and decode DataFrame columns
parquet_dir = Path("parquets")
parquets = parquet_dir.glob("*.parquet")

chunks_list = [
    pd.read_parquet(str(f), engine='fastparquet') for f in parquets
]

# Concatenate DataFrames
df_parquet = pd.concat(chunks_list, ignore_index=True)

License

GNU Affero General Public License (AGPL-3.0)

This license ensures that the software remains open-source and free to use, modify, and distribute while requiring that any changes or enhancements made to the codebase are also made available to the community under the same terms.

Acknowledge
============

This program decompresses .dbc files to .dbf. This code is based on the work of Mark Adler madler@alumni.caltech.edu (zlib/blast), Pablo Fonseca (https://github.com/eaglebh/blast-dbf).

PySUS has further extended and adapted this code to create pyreaddbc. The original work of Mark Adler and Pablo Fonseca is much appreciated for its contribution to this project.

Note: pyreaddbc is maintained with funding from AlertaDengue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyreaddbc-2.0.3.tar.gz (25.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyreaddbc-2.0.3-cp313-cp313-win_amd64.whl (33.0 kB view details)

Uploaded CPython 3.13Windows x86-64

pyreaddbc-2.0.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.3-cp313-cp313-macosx_11_0_arm64.whl (31.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyreaddbc-2.0.3-cp312-cp312-win_amd64.whl (32.9 kB view details)

Uploaded CPython 3.12Windows x86-64

pyreaddbc-2.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.3-cp312-cp312-macosx_11_0_arm64.whl (31.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyreaddbc-2.0.3-cp311-cp311-win_amd64.whl (32.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pyreaddbc-2.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.3-cp311-cp311-macosx_11_0_arm64.whl (31.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyreaddbc-2.0.3-cp310-cp310-win_amd64.whl (33.0 kB view details)

Uploaded CPython 3.10Windows x86-64

pyreaddbc-2.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.3-cp310-cp310-macosx_11_0_arm64.whl (31.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyreaddbc-2.0.3-cp39-cp39-win_amd64.whl (32.9 kB view details)

Uploaded CPython 3.9Windows x86-64

pyreaddbc-2.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.3-cp39-cp39-macosx_11_0_arm64.whl (31.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pyreaddbc-2.0.3.tar.gz.

File metadata

  • Download URL: pyreaddbc-2.0.3.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3.tar.gz
Algorithm Hash digest
SHA256 7b790514aa9b68e57b90199dd578ccf8fe1a64d43884f12331a1e553b17fc883
MD5 dcbc102f10997a7ff610e8da3c3969b2
BLAKE2b-256 c228a204356a735fd2f55465247067220c453da845d76e88800ca4f37236e8f2

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyreaddbc-2.0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b8288cae92acdd714e7da756fd7b027cb86451ceac6da86579709b708c5bbeb1
MD5 0ea47e9e70c9d205c92e1dfdea80e16b
BLAKE2b-256 283b5810d68e683af96805722b4073c7a4a43e04bb43f1c357f8b9de133138cf

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0a5744d912064b7c43b2c5e0400da76bd6e8125c6e4b697bcd180857d30999eb
MD5 c5fd84852c1acfdad9430f78dd6356d0
BLAKE2b-256 4ed09f92f414c27e9c50e5ce1c57899a7182ee54c23aef8672b1498843c2a010

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 43b532e0c50de8d3c0fdb3e8a26854fdf413ae714adcf3c4ffc6cb63c6f77d91
MD5 b3fe3a1ba8982d66a5887d38f831fe10
BLAKE2b-256 2d6b750cf3d976fb06674d3ba18ab68a41538412a4a3643b2ebc4c161e5a0c2c

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f1118141580a01198691a2bef7b5d6d89273981824b9cdbd64a70730fb7951b
MD5 91ea952e5c77f087f3f30475484e18c6
BLAKE2b-256 a4f6d57a12a1d16692601209d12e2c242eae580eaba3c8a33e4b858d21b1cd89

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyreaddbc-2.0.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 15de869cbd92990750156ddccd9c4a183df83edba96515901588c7e445b6f3a0
MD5 e174f7bc6663b57375a14a1959473f7e
BLAKE2b-256 ca5e1e38dcba19ae2fb0a740a68f6a578cc98cab8adf200a881461b691bc1b6d

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c4f590af1b23efa17e1e9e24ca45cd131a85da73de8de91258f1468c17d493d9
MD5 ba9a4e7e9a7bee0a104aa280b8e1660e
BLAKE2b-256 e1f245c334b2f843c4aedc01bfa4337609609365defd2b687c4846985deb0718

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a0fa1c19888565e59f868b2628ada1dc68a324a83a1c945a95118eb9b74cefe
MD5 15199c17e71951c1523d7c10fc02436e
BLAKE2b-256 614f3b4a47755cb714289e38ac304bdf290bfef868cdce23a8296489a5f69f66

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01f4a452972c2c13684b9bedd885ba094c2fbe99da9007dba06f7eab5234f9b0
MD5 194c44b88e243cfa79240d2c67b050c2
BLAKE2b-256 2d445108f27726f420aa90c6c7abbec64d67465800bde62afe26ad226cc95f75

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyreaddbc-2.0.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0d90da83360370695344be426e5f23635fd587647d10ebd7367909c8c83c0b28
MD5 a9b2ca1f4dc102b9b4aed3f1db587cfb
BLAKE2b-256 4e8283f855b77d2c97f36e4fad795b9a58ea09271e3567bacaa099c58b6ac5b4

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d5a69f3c378fbe46e0448ca791c3e21d697c078b4c7f3ed2aac8d6679e406a80
MD5 752b7079b76e2d31564eda2a1f32a5c0
BLAKE2b-256 89cfd881512da031b7fed2dd1f37bc508e7251ec76d5d7d17b761025daeee0bd

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 905e3b18e69f72a07beb6f94584a16ad011363437646d174ce093660c26a9b16
MD5 6be53e11bd5fc6d28eed7165f5e2cda6
BLAKE2b-256 645892f0037eee1ca7c7549fdcdfbd7a91f13ad14ce4610a30f8288676445911

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 248006d84b063a41de3518bcdc70076bcb3dea443efebd9614707e823d2e2013
MD5 ba2205f6ea491ee97039f76233005403
BLAKE2b-256 7b65e7f23cd637a035ad21046fd27a09c293c011e1c51fb259b952c7e486d09f

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyreaddbc-2.0.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 72159407a701a0a89320650421480b91496bb7456517489e3f004a419b45a6d0
MD5 fcdf7a389b6c515f039a1b6e29b0bfee
BLAKE2b-256 85f66feffff2993605e7cd8bb9f71e64aa47a58d6aa7d0489ff8a75492b284f1

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 347de563d0b27898fa75b1f3ee723cc9cc0c9505ad09e0e242d23203d97c955f
MD5 e32264f0a70a7ed5ff2d705e45749e83
BLAKE2b-256 0d5d090ee45a9ec4c88123037efe07b149c4eb2985c3e7a26128ccbee0e3a54a

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cbc3fbe69629b978f761e16a821c2be44d92d7e6e2a3c823964c437d68e6ea5a
MD5 557dae0da2a0aebff5901b732659a087
BLAKE2b-256 3eddbd6e636e42a0f8de2276eb537006ff5fc2448f8a5d76dd6d9ba090f45162

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f481a0a9879994a071cf04d5f2f672e03ca58875cdc0cdc0a48d46db5239b19
MD5 4b3f9a39a41aded1baaeb10fcdba407b
BLAKE2b-256 f7249a3abde4bfd80baf25d8d11d8915d96ad6a1eacafcb01a61509fdde53f8c

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyreaddbc-2.0.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyreaddbc-2.0.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 139726978e9d57cebeb862c9b0ff94758774ebe00e1d68fe03e474ec12a96224
MD5 9991714ee479c43ca8dba8d4a0876817
BLAKE2b-256 c330dee59dcf0a3f435a970d33260da0ab0766f9e6818988328429130599a65c

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5030f19d1a5c6bab4d69ef60f98a860f54cda78008e35bf456132bc8ea1ebce8
MD5 c77f504ecbc7587584b7dd18a853115a
BLAKE2b-256 31698f704666d3ae7d2dfd97508350a5e8a167c04e5ded674ecab458271d91c5

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c86662920422defae8e4c85bc2ad3ca3bd54aeb69a87d673e0615738cc2d007
MD5 c57d1e0b350d63da77614b3701a9efb2
BLAKE2b-256 cd2d796625359e838bb18525868795553cc23e84b2f96414976622134d4f4749

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyreaddbc-2.0.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de529ca9fe169809904dfe92aec9e84f6757f081009105078339080927559bf6
MD5 68f9923cc5f158a141c6f5a96531381f
BLAKE2b-256 65232e403ab64e79d5c913b45de7b2827ae919d8ffba5f250ad8447d0215b2ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page