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.4.tar.gz (26.3 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.4-cp313-cp313-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.13Windows x86-64

pyreaddbc-2.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.4-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.2 kB view details)

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

pyreaddbc-2.0.4-cp313-cp313-macosx_11_0_arm64.whl (31.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyreaddbc-2.0.4-cp312-cp312-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.12Windows x86-64

pyreaddbc-2.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.2 kB view details)

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

pyreaddbc-2.0.4-cp312-cp312-macosx_11_0_arm64.whl (31.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyreaddbc-2.0.4-cp311-cp311-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.11Windows x86-64

pyreaddbc-2.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.2 kB view details)

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

pyreaddbc-2.0.4-cp311-cp311-macosx_11_0_arm64.whl (31.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyreaddbc-2.0.4-cp310-cp310-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.10Windows x86-64

pyreaddbc-2.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.2 kB view details)

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

pyreaddbc-2.0.4-cp310-cp310-macosx_11_0_arm64.whl (31.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyreaddbc-2.0.4-cp39-cp39-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.9Windows x86-64

pyreaddbc-2.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

pyreaddbc-2.0.4-cp39-cp39-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.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyreaddbc-2.0.4-cp39-cp39-macosx_11_0_arm64.whl (31.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4.tar.gz
  • Upload date:
  • Size: 26.3 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.4.tar.gz
Algorithm Hash digest
SHA256 e3ce8f12b0feec3d6bf2b3722309346f015a22e8279f9789e9eeda869d8b33d1
MD5 7124242a0438c410d2cca5da040ac07f
BLAKE2b-256 57138982e2c83d74219b969ad9018ccddcd424002830f14cceaf801a375d3cc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 33.2 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e07862c8409d69c961268d26a08c52d468ac259ab964dc2fc24822fbc790c930
MD5 753124b215b0e2133e2701f0078e696e
BLAKE2b-256 0ae74818b2c7a96951d9dc7ea6b5cda3656588848a2057add96733838c58a26c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83ed8c757b85c6c48c3fc961edb829a75ce4ee32483a91659d5705e57c6fa3df
MD5 805d959007c6537b49befcc6e2c4fc74
BLAKE2b-256 db02ed73c48698cb23bb3f6303cb9b1e78b790f21dff95196262d968a23bca77

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.4-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.4-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 def263c24f62a110bfb8af040df5c602e7381df9ea91e824d48a63a00917b2c5
MD5 2fcf0c5bd45c6d8c25d54866d35318ad
BLAKE2b-256 85dc3bc61f06a9da2f663ef3643f51f8829d8a89d0bd7295fe81adcf77f19026

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 882e4687adc47ae7702fe39fd139f27a2744feb6dc276463b761dac6d490a382
MD5 b82b00f2937d18bb00f6a9c41f3e01fb
BLAKE2b-256 aeeaec8e8d5b8b4bbcd4a1ae4be225495858ed47ee916b04104049e3f039d3e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 33.2 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fb47791187148753c9dd6fbf244924ff53f59db02111f9b122e0f494a8a9f6c0
MD5 e054bf1469a7459e93e6ad98540273ae
BLAKE2b-256 b729dde4414d0403fb814aa8c1812878f6e2d012dd01f388d33301ebaf4109be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c053370eee23ba23589369128fac5ca81a797db5e61e8bf67f1b4b325b69fa35
MD5 473b6df14a3151c212e6acaa150826c4
BLAKE2b-256 2fe9f2102e044c043510e6108a93486efe1ae5657f09380f8b07f45981a5fd42

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.4-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.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 754c1c2eb23afdad25d71edbcde0aeb8388fd297e28b094ee209c95fead6e92b
MD5 c3abd6863828220154bdfc5625b62233
BLAKE2b-256 3722ff0a5c55b3792fac65ab70a7e0804d73297b36b5647ebf3ec587ead914a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90dedbd59cb8cf588352610132396a74b32d4536ab718239c8cb120c0579d046
MD5 1eed646917bcaf4fa1010fd611795b4c
BLAKE2b-256 977650615400d00f8d5d2da05705697c426af14e8ec4e8f577087c5a77fccd36

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 33.2 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6396b0b0faeb64994325e59261e97f2a83dfda0727b0b719226c1af2d06556d9
MD5 d96d3dd814b9f3d2569dc938d4369d72
BLAKE2b-256 829090a40bf161a64f1aa2f108a157c3b5d0279562f39d35a11606ef82510c77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dad1dc53137af6cc57a9f5b6d9848c5cff2df3dc0e81183c5dff80f71df7adac
MD5 985a9fa975eec0041f5d1a7c0a3581fe
BLAKE2b-256 a0879bc31462a0ec1f8a9bf167821fd8c8d0d1a5b89e75071fc1c436557c8ca5

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.4-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.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55447a8ac87c7de983cbe38b1305a2bfdd5bbabeaddd4e5c7338f4643c3a8770
MD5 3da3684a70c45aba9ff8dfbd0a0f56d9
BLAKE2b-256 2429c1bcadf3b24787b50cdd7ed83f9b2ce6131c9963c2b374800f38e3b3410a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b469ee9442ba93d1a81ca37851082303fbe63dd9d4c63a4285deaf452c790038
MD5 67c20a285d4ae2b8158760c4e3060d73
BLAKE2b-256 d570fc339d7014d969c2cb06b2ee1ad057f4c77f16aea93e284f2daccbbacbbd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 33.2 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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a09a7d11000315d007486e23e5291820dd0144916c3faa2aae79a7a5a625ca32
MD5 81cfd2b22560720793e26b7226f94473
BLAKE2b-256 5dc74ba148ff809e17638a8225df2237b340d217b102e2a7fa9939f37f29d3b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eb6bb262e3d7445b2cefefafe5bc9d78f993ee58830e830a0cf172438647a8c5
MD5 89045f07b291aad49d9d69160599e0b3
BLAKE2b-256 199aff832de161a22682186fee3d92b51e597344ca9a0a0a24010554845307d8

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.4-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.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51d2458a0a9b4fb6017558051ed360aa9ed7cdef0f6feaeaf0687cb5a6e37cbb
MD5 5eea0d6211409a9d79b33812fbf6e61c
BLAKE2b-256 09fb3c12573c9a8e300ce4fc238be6cedddcd6f45e40cef0c31d530f21d0fda0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a45d4aa2be0173e0bccee64e76847e96a02fcdd02cb449be92e99b0a76f8f0f8
MD5 52fe66cc305d99ca3fd41b0846afab98
BLAKE2b-256 9ef3dae6cf2ff5462af1e9e6db8a8e8867eb39bc768665d68871a7f9d39844d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyreaddbc-2.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 33.2 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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bab1a14feaf39aff81527d93a74a218af83235509e7782ec4a26ed746b40c200
MD5 b767940e87b84a445fe7729619aff2e3
BLAKE2b-256 a17529c6b8b2ed7fc6723cc764b14ad181a5b8079ebc18814aae96fce9fcf0ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ae84f224b3a3b4d80c4450ded13425347d7d2ad8b4bd08399e2f7a00b22ae92
MD5 68d7a4eca85ff61e8b1f497e7a4aa8c0
BLAKE2b-256 8436bbf926a9fedafcf6b49f372039ce056fea976a890d66d0a59cee78f13ebf

See more details on using hashes here.

File details

Details for the file pyreaddbc-2.0.4-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.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 854674fc5f9728c8296fb787dba0bcc00affdd6b227cc9173d401275f16d01e2
MD5 961019fd33b0323b34cfc818be8c593e
BLAKE2b-256 276a8ed9741511dfca231ad13b5447408a394d13c337dfe39fde7e14e2cea451

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyreaddbc-2.0.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56a1ad297dda409d0af68349a5b26cb1e61f158e11046a7d7387a6b140913fc6
MD5 00800f32c88c9f8f778a3660ca501df0
BLAKE2b-256 98580a5f487f471746555195ace08c25aafe77fcf9425e4313817f5862345971

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