is_file_text: Determine whether a file is "plain-text" or some sort of...

Description Usage Arguments Value Examples

View source: R/is_file_text.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(datasets)
export(iris, yml_file <- tempfile(fileext = ".yml"))
is_file_text(yml_file) # TRUE

export(iris, sav_file <- tempfile(fileext = ".sav"))
is_file_text(sav_file) # FALSE

# cleanup
unlink(yml_file)
unlink(sav_file)

rio documentation built on Nov. 22, 2021, 9:07 a.m.