| Title: | Read Data Stored in 'DBC' (Compressed 'DBF') Files |
| Description: | Functions for reading and decompressing the 'DBC' (compressed 'DBF') files. Please note that this is the file format used by the Brazilian Ministry of Health ('DATASUS') to publish healthcare datasets. It is not related to the 'FoxPro' or 'CANdb' 'DBC' file formats. |
| Version: | 1.2.0 |
| Author: | Daniela Petruzalek [aut, cre, cph], Mark Adler [cph, ctb], Pablo Marcondes Fonseca [cph, ctb] |
| Depends: | R (≥ 3.3.0) |
| Imports: | foreign |
| Maintainer: | Daniela Petruzalek <daniela.petruzalek@gmail.com> |
| URL: | https://github.com/danicat/read.dbc |
| BugReports: | https://github.com/danicat/read.dbc/issues |
| Copyright: | 2016 Daniela Petruzalek |
| License: | AGPL-3 |
| Encoding: | UTF-8 |
| Date: | 2025-11-19 |
| RoxygenNote: | 7.3.2 |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | yes |
| Packaged: | 2025-11-19 20:16:30 UTC; danicat |
| Repository: | CRAN |
| Date/Publication: | 2025-11-28 10:00:02 UTC |
Decompress a DBC file
Description
This function allows you decompress a DBC file. When decompressed, it becomes a regular DBF file.
Usage
dbc2dbf(input.file, output.file)
Arguments
input.file |
The name of the DBC file (including extension) |
output.file |
The output file name (including extension) |
Details
DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). This is a proprietary file format used by the Brazilian government to publish public healthcare data. When decompressed, it becomes a regular DBF file.
Please note that this is the file format is not related to the FoxPro or CANdb DBC file formats.
Value
Return TRUE if succeed, FALSE otherwise.
Author(s)
Daniela Petruzalek, daniela.petruzalek@gmail.com
Source
The internal C code for dbc2dbf is based on blast decompressor and blast-dbf (see References).
References
blast source code in C: https://github.com/madler/zlib/tree/master/contrib/blast
blast-dbf, DBC to DBF command-line decompression tool: https://github.com/eaglebh/blast-dbf
See Also
Examples
# Input file name
input <- system.file("files/sids.dbc", package = "read.dbc")
# Output file name
output <- tempfile(fileext = ".dbf")
# The call returns TRUE on success
if( dbc2dbf(input.file = input, output.file = output) ) {
print("File decompressed!")
# do things with the file
}
file.remove(output) # clean up example, don't do in real life :)
Compress a standard DBF file into a DBC file (Experimental)
Description
This function compresses a standard DBF file into a DBC file using the PKWare DCL Implode algorithm. This functionality is experimental and may be subject to change.
Usage
dbf2dbc(input, output)
Arguments
input |
The input DBF file path. |
output |
The output DBC file path. |
Value
TRUE if successful.
Examples
## Not run:
# Compress a file
dbf2dbc("data.dbf", "data.dbc")
## End(Not run)
Read Data Stored in DBC (Compressed DBF) Files
Description
This function allows you to read a DBC (compressed DBF) file into a data frame.
Usage
read.dbc(file, ...)
Arguments
file |
The name of the DBC file (including extension) |
... |
Further arguments to be passed to |
Details
DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). This is a proprietary file format used by the Brazilian government to publish public healthcare data, and it is not related to the FoxPro or CANdb DBC file formats.
The read.dbc function will decompress the input DBC file into a temporary DBF file and call read.dbf from the foreign package to read it into a data frame.
Value
A data.frame of the data from the DBC file.
Note
DATASUS is the name of the Department of Informatics of the Brazilian Health System (Sistema Único de Saúde - SUS) and is responsible for publishing public healthcare data in Brazil. Besides the DATASUS, the Brazilian National Agency for Supplementary Health (ANS) also uses this file format for its public data.
This function was tested using files from both DATASUS and ANS to ensure compliance with the format, and hence ensure its usability by researchers.
Neither this project, nor its author, has any association with the Brazilian government.
Author(s)
Daniela Petruzalek, daniela.petruzalek@gmail.com
See Also
Examples
# The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package.
file <- system.file("files/sids.dbc", package="read.dbc")
sids <- read.dbc(file)
str(sids)
summary(sids)
# This is a small subset of U.S. NOAA storm database.
file <- system.file("files/storm.dbc", package="read.dbc")
storm <- read.dbc(file)
head(storm)
str(storm)