Read and Write Data in DCF Format

DESCRIPTION:

Reads or writes an S-PLUS object from or to a file in the Debian Control File format.

USAGE:

read.dcf(file, fields=character(0), convertSplusLines=TRUE)
write.dcf(x, file="", append=FALSE, 
    indent=0.1 * getOption("width"), 
    width=0.9 * getOption("width"))

OPTIONAL ARGUMENTS:

file
a character string naming either a connection or a file. For write.dcf, the default "" specifies output to the console.
fields
The fields to read. By default, reads all fields.
convertSplusLines
x
The object to write. Typically, x is a data frame; however, if it is not, then S-PLUS attempts to coerce x to a data frame.
append
logical. By default, FALSE, indicating that the contents of the existing file are deleted and the output overwrites the file. If TRUE, the output is appended to the file.
indent
a positive integer specifying how many character spaces to indent any wrapping lines in the output.
width
a positive integer specifying the target column for wrapping lines in the output.

DETAILS:

The DCF format stores the contents of databases as plain text files for easy reading. S-PLUS uses DCF to store system information (for example, descriptions, contents of packages, and so on).

S-PLUS implements the following rules for DCF:
    A database consists of one or more records, each with one or more named fields. Not every record must contain each field. A field can appear only once in a record.
    Regular lines cannot begin with white space.
    Regular lines are of form tag:value. That is, they have a name tag and a value for the field, separated by a colon ( :). (Only the first : counts.) The value can be empty. (That is whitespace only.)
    Lines starting with whitespace are continuation lines (of the preceding field) if at least one character in the line is non-whitespace.
    Records are separated by one or more empty (=whitespace only) lines.

read.dcf returns a character matrix with one line per record and one column per field. It ignores leading and trailing white spaces in field values. If a tag name is specified, but the corresponding value is empty, an empty string of length 0 is returned. If the tag name of a field is not used in a record, then NA is returned. If the database contains multiple records with the same tag name, the last one found is returned.

SEE ALSO:

EXAMPLES:

## Create a reduced version of the main library section DESCRIPTION:
x <- read.dcf(file=system.file("DESCRIPTION", package="main"),
              fields=c("Package", "Version", "Maintainer"))
write.dcf(x)