Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

readLines.mvb

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

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"

mvbutils

Workspace Organization, Code and Documentation Editing, Package Prep and Editing, Etc

v2.8.232
GPL (>= 2)
Authors
Mark V. Bravington <mark.bravington@csiro.au>
Initial release
2018-12-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.