load_text_content {fscache}R Documentation

Load the content of a text file.

Description

Load the content of a text file, trying to guess file encoding. The content is returned as a single character value.

Usage

load_text_content(path, min.confidence = 0)

Arguments

path

Path to the file from which to load content.

min.confidence

The minimum confidence value (between 0 and 1)

Value

The content of the file as a single character value, NA_character_ if encoding was not recognized.

Examples

# Create a file in Latin-1 encoding
text_file <- tempfile('myfile', fileext = '.txt')
dir.create(dirname(text_file), recursive = TRUE)
x <- iconv("Qui sème le vent récolte la tempête.",
           from = "utf8", to = "latin1")
stringi::stri_write_lines(x, text_file, encoding = "latin1")

# Load its content
content <- fscache::load_text_content(text_file)
content

# Remove file
unlink(text_file)


[Package fscache version 1.0.5 Index]