Read Data Stored in DBC (Compressed DBF) Files

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.

Author: Daniela Petruzalek
e-mail: [email protected]
License: AGPLv3


read.dbc is a R package to enable importing data from DBC (compressed DBF) files into data frames. Please note that this is the file format used by the Brazilian Ministry of Health (DATASUS), and it is not related to the Microsoft FoxPro or CANdb DBC file formats.

DATASUS is the name of the Department of Informatics of Brazilian Health System. It is the agency resposible for publishing Brazilian public healthcare data. Besides DATASUS, the Brazilian National Agency for Supplementary Health (ANS) also uses this file format for its public data.

This code was tested using files from both DATASUS and ANS to ensure compliance with the format, and hence ensure its usability by researchers.

This project is based on the work of Mark Adler (blast) and Pablo Fonseca (blast-dbf).

As a final note, neither this project, nor its author, is related in any way to the Brazilian government.


For a complete description of the changes, please check

Repository Contents

  • this file.
  • change history.
  • src/blast.c: decompression tools for PKWare Data Compression Library (DCL).
  • src/blast.h: blast.c header and usage notes.
  • src/dbc2dbf.c: the main program to decompress the dbc files to dbf.
  • R/read.dbc.R: the code for reading .dbc files within R.
  • R/dbc2dbf.R: a helper function to decompress the .dbc files, it works as a wrapper to the "blast" code.
  • man/*: package manuals
  • inst/*: test and misc files


As of June, 7 of 2016, this package officialy became part of CRAN (The Comprehensive R Archive Network). Therefore, it's current stable version can be installed by running install.packages:


In case you want to install the development version of this package, you still can do it using the devtools library:



Reading a DBC file to a data frame:

    # The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package.
    x <- read.dbc(system.file("files/sids.dbc", package="read.dbc"))
    # This is a small subset of U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database.
    storm <- read.dbc(system.file("files/storm.dbc", package="read.dbc"))
    # Don't run!
    # The following code will download data from the "Declarations of Death" database for
    # the Brazilian state of Parana, year 2013. Source: DATASUS / Brazilian Ministry of Health
    url <- ""
    download.file(url, destfile = "DOPR2013.dbc")
    dopr <- read.dbc("DOPR2013.dbc")

Decompressing a DBC file to a DBF:

    # Input file name
    in.f  <- system.file("files/sids.dbc", package = "read.dbc")
    # Output file name
    out.f <- tempfile(fileext = ".dbc")
    # The call return logi = TRUE on success
    if( dbc2dbf(input.file = in.f, output.file = out.f) ) {
         print("File decompressed!")

Contact Info

If you have any questions, please contact me at [email protected]. You may also follow me on Twitter.


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0.5 by Daniela Petruzalek, 4 years ago

Report a bug at

Browse source code at

Authors: Daniela Petruzalek [aut, cre]

Documentation:   PDF Manual  

AGPL-3 license

Imports foreign

See at CRAN