Reads a cdb file

Share:

Description

This function reads a cdb file (or its text version) and creates a data frame with the keys and values.

Usage

1
read.cdb(file, type=c("cdb","txt"))

Arguments

file

The name of the cdb file to read.

type

A character string describing the type of file. Value cdb reads a file with the native format; txt needs a text record format. See the Details section.

Details

This function reads data files in the cdb format or in its text version. The format is described in the documents of the reference section.

It reads all the keys and values and transforms them as a data frame with two columns.

Value

An object of the class data.frame with two columns: The first one collects the keys and the second one shows the values.

Author(s)

Emilio Torres Manzanera

References

D. J. Bernstein The cdbmake and cdbdump programs http://cr.yp.to/cdb/cdbmake.html

Yusuke Shinyama (2003) Constant Database (cdb) Internals http://www.unixuser.org/~euske/doc/cdbinternals/

Michael Tokarev (2012) TinyCDB - a Constant DataBase http://www.corpit.ru/mjt/tinycdb.html

See Also

write.cdb

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
packages <- rownames(as.data.frame(installed.packages()))
set.seed(123)
a <- data.frame(key=sample(packages, 10, replace = TRUE),
                value=sample(packages, 10, replace = TRUE))
write.cdb(a, "Base.txt", type="txt")

b <- read.cdb("Base.txt", type="txt")
b

c <- read.cdb(system.file("extdata", "example.cdb",
                        package = "cdb"))
c

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.