R: Transform a text file

transform_lines_enc {enc} | R Documentation

## Transform a text file

### 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

    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()`

[Package enc version 0.2.2 Index]