Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Passing ... on to data.table::fread #19

Merged
merged 1 commit into from
Jul 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/dwca.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dwca_read <- function(input, read = FALSE, ...){
# get datasets metadata
dataset_meta <- lapply(files$datasets_meta, EML::read_eml)
# get data
datout <- read_data(files$data_paths, read)
datout <- read_data(files$data_paths, read, ...)

structure(list(files = files,
highmeta = highmeta,
Expand Down Expand Up @@ -171,23 +171,23 @@ data_paths <- function(x){
file.path(basedir, xml_text(xml_find_all(meta, "//files/location")))
}

read_data <- function(x, read){
read_data <- function(x, read, ...){
if ( read ) {
datout <- list()
for (i in seq_along(x)) {
datout[[basename(x[[i]])]] <- try_read(x[[i]])
datout[[basename(x[[i]])]] <- try_read(x[[i]], ...)
}
datout
} else {
x
}
}

try_read <- function(z){
try_read <- function(z, ...){
res <- tryCatch(
suppressWarnings(
data.table::fread(z, stringsAsFactors = FALSE, data.table = FALSE,
sep = "\t", quote = "")
sep = "\t", quote = "", ...)
), error = function(e) e
)
if ( inherits(res, "simpleError") ) {
Expand Down