rio (version 0.5.26)

is_file_text: Determine whether a file is “plain-text” or some sort of binary format

Description

Determine whether a file is “plain-text” or some sort of binary format

Usage

is_file_text(file, maxsize = Inf, text_bytes = as.raw(c(7:16, 18, 19, 32:255)))

Arguments

file

Path to the file

maxsize

Maximum number of bytes to read

text_bytes

Which characters are used by normal text (though not necessarily just ASCII). To detect just ASCII, the following value can be used: as.raw(c(7:16, 18, 19, 32:127))

Value

A logical

Examples

Run this code
# NOT RUN {
library(datasets)
export(iris, "iris.yml")
is_file_text("iris.yml") # TRUE

export(iris, "iris.sav")
is_file_text("iris.sav") # FALSE

# cleanup
unlink("iris.yml")
unlink("iris.sav")

# }

Run the code above in your browser using DataLab