readLines.mvb {mvbutils}R Documentation

Read text lines from a connection

Description

Reads text lines from a connection (just like readLines), but optionally only until a specfied string is found.

Usage

  readLines.mvb( con=stdin(), n=-1, ok=TRUE, EOF=as.character( NA), line.count=FALSE)

Arguments

con

A connection object or a character string.

n

integer. The (maximal) number of lines to read. Negative values indicate that one should read up to the end of the connection.

ok

logical. Is it OK to reach the end of the connection before ‘n > 0’ lines are read? If not, an error will be generated.

EOF

character. If the current line matches the EOF, it's treated as an end-of-file, and the read stops. The connection is left OPEN so that subsequent reads work.

line.count

(default FALSE) see Value.

Details

Apart from stopping if the EOF line is encountered, and as noted with line.count==TRUE, behaviour should be as for readLines.

Value

A character vector of length the number of lines read. If line.count==TRUE, it will also have an attribute "line.count" showing the number of lines read.

See Also

source.mvb, current.source, flatdoc

Examples

tt <- tempfile()
cat( letters[ 1:6], sep="\n", file=tt)
the.data <- readLines.mvb( tt, EOF="d")
unlink( tt)
the.data # [1] "a" "b" "c"

[Package mvbutils version 2.8.232 Index]