read_lines_enc

0th

Percentile

Reads from a text file

This function is a drop-in replacement for readLines() from disk files. It always returns text in the UTF-8 encoding and never warns on missing EOL on the last line.

try_read_lines_enc() is a variant that returns an empty character vector on error, with a warning.

Usage
read_lines_enc(path, file_encoding = "UTF-8", n = -1L, ok = TRUE,
  skipNul = FALSE)

try_read_lines_enc(path, file_encoding = "UTF-8", n = -1L, ok = TRUE, skipNul = FALSE)

Arguments
path

Path to the file

file_encoding

The encoding to assume for the input file.

n

integer. The (maximal) number of lines to read. Negative values indicate that one should read up to the end of input on 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.

skipNul

logical: should nuls be skipped?

See Also

readr::read_lines() for a faster alternative.

Other file functions: transform_lines_enc, write_lines_enc

Aliases
  • read_lines_enc
  • try_read_lines_enc
Documentation reproduced from package enc, version 0.2.0, License: GPL-3

Community examples

Looks like there are no examples yet.