readTokens: Read the remaining tokens from a 'Tokenizer' up to the end of...

View source: R/Tokenizer.R

readTokensR Documentation

Read the remaining tokens from a Tokenizer up to the end of the underlying file.

Description

A comfortable way to read all remaining tokens from a file open through a tokenizer..

A comfortable way to read all lines from a file. Syntactic sugar for readTokens(Tokenizer$new(filename),delims=c(10L,13L)).

Usage

# readTokens(mytok)
# readTokens(Tokenizer$new("myfile.txt"),c("0x20L"))

# readlines("myfile.txt")

Arguments

tok

The tokenizer from which to read.

delims

The delimiters to use for the remaining tokens.

filename

The file to read.

Value

A vector of strings representing the read tokens.

A vector of strings representing the lines of the file.

Examples

## Not run: 
tok<-Tokenizer$new("myfile.txt")           # create a tokenizer
tok$nextToken()                            # read some tokens
readTokens(tok,as.integer(charToRaw("+"))) # read the rest of the file, now delimited by "+"
readTokens(Tokenizer$new("myfile.txt"))    # read all tokens
readTokens("myfile.txt")                   # same as above, syntactic sugar

## End(Not run)
## Not run: 
readlines("myfile.txt")

## End(Not run)

wamserma/R-wmisc documentation built on March 19, 2023, 3:06 a.m.