dbc-to-dbf


Namedbc-to-dbf JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryConvert DBC files (compressed DBF - DATASUS) into DBF using the PKWare BLAST decompression algorithm
upload_time2025-07-24 23:00:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licensezlib License Copyright (c) 2025 Mozar Silva This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.
keywords dbc datasus dbf pkware blast decompression converter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dbc-to-dbf

A pure Python utility to convert `.dbc` files into standard `.dbf` format — commonly used in public health data from the Brazilian government.

`.dbc` files are a compressed form of `.dbf` (dBase format) files used by **DATASUS**, the Department of Informatics of the **Brazilian Unified Health System (SUS)**.  
DATASUS provides large-scale public health datasets (such as hospital admissions, mortality records, disease surveillance, and more) in `.dbc` format to reduce file size and facilitate distribution.

These `.dbc` files are compressed using a legacy algorithm known as **PKWare DCL "implode"**, originally used in older versions of ZIP files. This format is no longer widely supported, and modern decompression libraries (like `zipfile` or `gzip`) **do not handle `.dbc` files**.

This project provides a **pure Python implementation** of the **BLAST decompression algorithm**, which is compatible with the compression used in `.dbc` files. It is a direct, object-oriented rewrite of `blast.c` by Mark Adler (co-author of zlib), adapted and modernized for Python usage.

With this library, researchers, data analysts, public health professionals, and developers can easily **extract health data from DATASUS** in a readable and processable format — enabling analysis, dashboards, research, and more.

---

## References

- DATASUS homepage: [https://datasus.saude.gov.br](https://datasus.saude.gov.br)
- File format documentation (Portuguese): [https://ftp.datasus.gov.br/](https://ftp.datasus.gov.br/)
- Compression format background: [https://github.com/madler/blast](https://github.com/madler/blast)

---

## 📦 Installation

Install directly from PyPI:

    pip install dbc-to-dbf

Or clone from GitHub and install locally:

    git clone https://github.com/mozaru/dbc-to-dbf.git
    cd dbc-to-dbf
    pip install .

---

## 🚀 Usage


### ➤ Option 1: Import and use in Python code

```python
from dbctodbf import DBCDecompress

dbc = DBCDecompress()
dbc.decompressFile("input.dbc", "output.dbf")
```

### ➤ Option 2: Run as a module

```bash
python -m dbctodbf input.dbc output.dbf
```

### ➤ Option 3: Use CLI command (installed with pip)

```bash
dbc2dbf input.dbc output.dbf
```

---

## 🔧 Features

- Fully implemented in pure Python (no native extensions)
- Converts `.dbc` (compressed DBF) to `.dbf`
- Based on Mark Adler's `blast.c`, adapted and improved using modern Python
- Object-oriented design for easy integration and reuse
- Easily testable and extendable

---

## 🖥️ Example CLI script (for custom use)

```python

    import sys
    from dbctodbf import DBCDecompress

    if __name__ == "__main__":
        if len(sys.argv) != 3:
            print("Uso: python script.py <entrada.dbc> <saida.dbf>")
            sys.exit(1)

        input_file = sys.argv[1]
        output_file = sys.argv[2]

        try:
            dbc2dbf = DBCDecompress()
            dbc2dbf.decompressFile(input_file, output_file)
            print(f"Conversão concluída: {output_file}")
        except Exception as e:
            print(f"Erro ao converter: {e}")
            sys.exit(1)
```

---

## 🔗 Links

- 📂 GitHub: [https://github.com/mozaru/dbc-to-dbf](https://github.com/mozaru/dbc-to-dbf)
- 📦 PyPI: _(coming soon)_

---

## 🧑‍💻 Contributing

Pull requests are welcome!  
If you find a bug or have a suggestion, feel free to open an issue.

---

## ⚖️ License

This project is licensed under the zlib License (see LICENSE file).

Original decompression algorithm by Mark Adler <madler@alumni.caltech.edu>  
Python port and enhancements by Mozar Silva <mozar.silva@11tech.com.br> or <mozar.silva@gmail.com.br>.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dbc-to-dbf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "dbc, DATASUS, dbf, pkware, blast, decompression, converter",
    "author": null,
    "author_email": "Mozar Silva <mozar.silva@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fe/b7/a326a1fdeb3064274c71b08a8e9650d753559c1fbc9d8bd3650b7dc6705d/dbc_to_dbf-1.0.1.tar.gz",
    "platform": null,
    "description": "# dbc-to-dbf\r\n\r\nA pure Python utility to convert `.dbc` files into standard `.dbf` format \u2014 commonly used in public health data from the Brazilian government.\r\n\r\n`.dbc` files are a compressed form of `.dbf` (dBase format) files used by **DATASUS**, the Department of Informatics of the **Brazilian Unified Health System (SUS)**.  \r\nDATASUS provides large-scale public health datasets (such as hospital admissions, mortality records, disease surveillance, and more) in `.dbc` format to reduce file size and facilitate distribution.\r\n\r\nThese `.dbc` files are compressed using a legacy algorithm known as **PKWare DCL \"implode\"**, originally used in older versions of ZIP files. This format is no longer widely supported, and modern decompression libraries (like `zipfile` or `gzip`) **do not handle `.dbc` files**.\r\n\r\nThis project provides a **pure Python implementation** of the **BLAST decompression algorithm**, which is compatible with the compression used in `.dbc` files. It is a direct, object-oriented rewrite of `blast.c` by Mark Adler (co-author of zlib), adapted and modernized for Python usage.\r\n\r\nWith this library, researchers, data analysts, public health professionals, and developers can easily **extract health data from DATASUS** in a readable and processable format \u2014 enabling analysis, dashboards, research, and more.\r\n\r\n---\r\n\r\n## References\r\n\r\n- DATASUS homepage: [https://datasus.saude.gov.br](https://datasus.saude.gov.br)\r\n- File format documentation (Portuguese): [https://ftp.datasus.gov.br/](https://ftp.datasus.gov.br/)\r\n- Compression format background: [https://github.com/madler/blast](https://github.com/madler/blast)\r\n\r\n---\r\n\r\n## \ud83d\udce6 Installation\r\n\r\nInstall directly from PyPI:\r\n\r\n    pip install dbc-to-dbf\r\n\r\nOr clone from GitHub and install locally:\r\n\r\n    git clone https://github.com/mozaru/dbc-to-dbf.git\r\n    cd dbc-to-dbf\r\n    pip install .\r\n\r\n---\r\n\r\n## \ud83d\ude80 Usage\r\n\r\n\r\n### \u27a4 Option 1: Import and use in Python code\r\n\r\n```python\r\nfrom dbctodbf import DBCDecompress\r\n\r\ndbc = DBCDecompress()\r\ndbc.decompressFile(\"input.dbc\", \"output.dbf\")\r\n```\r\n\r\n### \u27a4 Option 2: Run as a module\r\n\r\n```bash\r\npython -m dbctodbf input.dbc output.dbf\r\n```\r\n\r\n### \u27a4 Option 3: Use CLI command (installed with pip)\r\n\r\n```bash\r\ndbc2dbf input.dbc output.dbf\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udd27 Features\r\n\r\n- Fully implemented in pure Python (no native extensions)\r\n- Converts `.dbc` (compressed DBF) to `.dbf`\r\n- Based on Mark Adler's `blast.c`, adapted and improved using modern Python\r\n- Object-oriented design for easy integration and reuse\r\n- Easily testable and extendable\r\n\r\n---\r\n\r\n## \ud83d\udda5\ufe0f Example CLI script (for custom use)\r\n\r\n```python\r\n\r\n    import sys\r\n    from dbctodbf import DBCDecompress\r\n\r\n    if __name__ == \"__main__\":\r\n        if len(sys.argv) != 3:\r\n            print(\"Uso: python script.py <entrada.dbc> <saida.dbf>\")\r\n            sys.exit(1)\r\n\r\n        input_file = sys.argv[1]\r\n        output_file = sys.argv[2]\r\n\r\n        try:\r\n            dbc2dbf = DBCDecompress()\r\n            dbc2dbf.decompressFile(input_file, output_file)\r\n            print(f\"Convers\u00e3o conclu\u00edda: {output_file}\")\r\n        except Exception as e:\r\n            print(f\"Erro ao converter: {e}\")\r\n            sys.exit(1)\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udd17 Links\r\n\r\n- \ud83d\udcc2 GitHub: [https://github.com/mozaru/dbc-to-dbf](https://github.com/mozaru/dbc-to-dbf)\r\n- \ud83d\udce6 PyPI: _(coming soon)_\r\n\r\n---\r\n\r\n## \ud83e\uddd1\u200d\ud83d\udcbb Contributing\r\n\r\nPull requests are welcome!  \r\nIf you find a bug or have a suggestion, feel free to open an issue.\r\n\r\n---\r\n\r\n## \u2696\ufe0f License\r\n\r\nThis project is licensed under the zlib License (see LICENSE file).\r\n\r\nOriginal decompression algorithm by Mark Adler <madler@alumni.caltech.edu>  \r\nPython port and enhancements by Mozar Silva <mozar.silva@11tech.com.br> or <mozar.silva@gmail.com.br>.\r\n\r\n",
    "bugtrack_url": null,
    "license": "zlib License\r\n        \r\n        Copyright (c) 2025 Mozar Silva\r\n        \r\n        This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\r\n        \r\n        Permission is granted to anyone to use this software for any purpose,\r\n        including commercial applications, and to alter it and redistribute it freely,\r\n        subject to the following restrictions:\r\n        \r\n        1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\r\n        \r\n        2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r\n        \r\n        3. This notice may not be removed or altered from any source distribution.\r\n        ",
    "summary": "Convert DBC files (compressed DBF - DATASUS) into DBF using the PKWare BLAST decompression algorithm",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/mozaru/dbc-to-dbf",
        "Repository": "https://github.com/mozaru/dbc-to-dbf"
    },
    "split_keywords": [
        "dbc",
        " datasus",
        " dbf",
        " pkware",
        " blast",
        " decompression",
        " converter"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f95f07da0e48af71a87ee36e3b167bf11e02d482ae06c47f2c6e5e55aad6d3f6",
                "md5": "bedb8be8fd2dab84ba2518a4c6a30c20",
                "sha256": "e0f894715e295e0dc46f8d55b434719af6892899974ec1da6231f64343c9a3b3"
            },
            "downloads": -1,
            "filename": "dbc_to_dbf-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bedb8be8fd2dab84ba2518a4c6a30c20",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8046,
            "upload_time": "2025-07-24T23:00:50",
            "upload_time_iso_8601": "2025-07-24T23:00:50.353578Z",
            "url": "https://files.pythonhosted.org/packages/f9/5f/07da0e48af71a87ee36e3b167bf11e02d482ae06c47f2c6e5e55aad6d3f6/dbc_to_dbf-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "feb7a326a1fdeb3064274c71b08a8e9650d753559c1fbc9d8bd3650b7dc6705d",
                "md5": "d166e9d678273adcd4b2de1ae32c7e12",
                "sha256": "2ca9c33c5790b987ee9018e253666770aca3d07f62afc84a54a137fd892fbd5f"
            },
            "downloads": -1,
            "filename": "dbc_to_dbf-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d166e9d678273adcd4b2de1ae32c7e12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6210,
            "upload_time": "2025-07-24T23:00:51",
            "upload_time_iso_8601": "2025-07-24T23:00:51.509012Z",
            "url": "https://files.pythonhosted.org/packages/fe/b7/a326a1fdeb3064274c71b08a8e9650d753559c1fbc9d8bd3650b7dc6705d/dbc_to_dbf-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-24 23:00:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mozaru",
    "github_project": "dbc-to-dbf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dbc-to-dbf"
}
        
Elapsed time: 1.03777s