read: A "Lazy" read version

Description Usage Arguments Details Examples

View source: R/read.R

Description

We often find that we are reading the same type of files over and over again. Read is a lazy version of the read.* functions. It tries to intelligently pick the appropriate reader from file extension or mime type info.

Usage

1
read(file, ..., verbose = FALSE, glob = TRUE)

Arguments

file

The file(s) or pattern of files to read.

...

options to pass to the reader functions.

verbose

Print messages?

glob

interpret patterns as globs?

Details

read will first check if the file exists as specified. If the file is not found then it will check if the file represents a pattern converted to a regular expression through glob2rx if glob=TRUE (default). Note that only one pattern can be considered if file is of length greater than 1 it will assume that exact file names are given.

If multiple files are given or found through pattern match then the results are given in a list, otherwise a single object is returned. For elements of said list, as in the case of a single result, an attempt will be made to convert results to a tibble through as_tibble.

Read will first look for readers with the following priority

  1. Known readers with the given name

  2. Known readers registered to handle the given mime-type

  3. Known readers registered to handle the given file extension

  4. Any loaded function of the form read.<<ext>>

  5. Any loaded function of the form read_<<ext>>

  6. Any loaded function of the form read<<ext>>

where <<ext>> is replaced by the extension of the file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
# reads all the xlsx files in a directory
read("*.xlsx")

# reads all the xlsx files in the data directory
read("data/*.xlsx")



## End(Not run)

halpo/short documentation built on July 18, 2019, 12:06 a.m.