checkExtensions: Automated Schema on Read File Extensions Checker

Description Usage Arguments See Also Examples

View source: R/CheckExtensions.R

Description

Checks to see if the given file exists and has one of the provided extensions.

Usage

1
checkExtensions(path = ".", extensions = NULL)

Arguments

path

a file to load or folder to recursively load.

extensions

a list of file extensions to check provided as lower case strings.

See Also

checkExtensions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Load the needed library.
library(SchemaOnRead)

## Define a new processor.
newProcessor <- function(path, ...) {

  # Check the file existance and extensions.
  if (!SchemaOnRead::checkExtensions(path, c("xyz"))) return(NULL)

  ## As an example, attempt to read an XYZ file as a CSV file.
  read.csv(path, header = FALSE)

}

## Define a new processors list.
newProcessors <- c(newProcessor, SchemaOnRead::simpleProcessors())

# Use the new processors list.
schemaOnRead(path = "../inst/extdata", processors = newProcessors)

SchemaOnRead documentation built on May 30, 2017, 8:12 a.m.