write.cdb: Writes a data frame to a text file

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This function writes a two column data frame to a text file using the cdb record format.

Usage

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

Arguments

x

An object that can be coerced as a data frame with two columns.

file

The name of the cdb file to write.

type

A character string describing the type of file. Value cdb does nothing; txt writes a text file using the cdb record format. See the Details section.

Details

This function writes a data frame to a file using the text version of the cdb format. The data frame (or the object) must have only two columns: The first one contains the keys and the second column are the values.

The text version of the constant databse is a file with several lines with the form of +klen,vlen:key->value followed by a newline. klen and vlen are the number of bytes in key and in value, respectively. The end of data is indicated by an extra newline.

Value

A text file with all the keys and values.

Note

This text file can be transformed into a native cdb format using external programs. You may use an external program (for instance, TinyCDB) to create a cdb version from the text file (see references for details). In future versions, a native creation of cdb files will be developed.

Author(s)

Emilio Torres Manzanera

References

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

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

See Also

read.cdb

Examples

1
2
3
4
5
6
7
set.seed(123)
a <- data.frame(key=rnorm(10),value=rnorm(10))
write.cdb(a, "Base.txt", type="txt")

# Create a cdb base using an external program.
# For instance, using the TinyCDB program:
## Not run: system("cdb -c Base.cdb Base.txt")

Example output

Loading required package: bitops

cdb documentation built on May 1, 2019, 8:47 p.m.