transform_lines_enc: Transform a text file

Description Usage Arguments Value See Also

View source: R/io.R

Description

Reads a file from disk, applies a function on the contents, and optionally writes the file back if different. The line ending separator of the input file is used if it can be read and contains at least one, otherwise native_eol() is used.

Usage

1
2
3
4
5
6
7
8
9
transform_lines_enc(
  path,
  fun,
  file_encoding = "UTF-8",
  ok = TRUE,
  skipNul = FALSE,
  write_back = TRUE,
  verbose = interactive()
)

Arguments

path

A vector of file paths.

fun

A function that returns a character vector.

file_encoding

The encoding to assume for the input file.

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?

write_back

Should the results of the transformation be written back to the file?

verbose

Should the function show a message with a list of changed files?

Value

A named logical vector of the same length as path that indicates if a file has changed (TRUE or FALSE), or if an error occurred (NA)

See Also

Other file functions: read_lines_enc(), write_lines_enc()


enc documentation built on Dec. 30, 2019, 1:06 a.m.