Learn R Programming

connector (version 0.1.0)

read_file: Read files based on the extension

Description

read_file() is the backbone of all read_cnt methods, where files are read from their source. The function is a wrapper around read_ext(), that controls the dispatch based on the file extension.

read_ext() controls which packages and functions are used to read the individual file extensions. Below is a list of all the pre-defined methods:

  • default: All extensions not listed below is attempted to be read with vroom::vroom()

  • parquet: arrow::read_parquet()

Usage

read_file(path, ...)

read_ext(path, ...)

# S3 method for default read_ext(path, ...)

# S3 method for txt read_ext(path, ...)

# S3 method for csv read_ext(path, delim = ",", ...)

# S3 method for parquet read_ext(path, ...)

# S3 method for rds read_ext(path, ...)

# S3 method for sas7bdat read_ext(path, ...)

# S3 method for xpt read_ext(path, ...)

# S3 method for yml read_ext(path, ...)

# S3 method for json read_ext(path, ...)

# S3 method for xlsx read_ext(path, ...)

Value

the result of the reading function

Arguments

path

character() Path to the file.

...

Other parameters passed on the functions behind the methods for each file extension.

delim

Single character used to separate fields within a record.

Examples

Run this code
# Read CSV file
temp_csv <- tempfile("iris", fileext = ".csv")
write.csv(iris, temp_csv, row.names = FALSE)
read_file(temp_csv)

Run the code above in your browser using DataLab