Skip to content

Commit

Permalink
Add tryCatch to loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Sep 29, 2023
1 parent 30f6a8b commit 9d55f69
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions R/xlsx_cutter.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,24 @@ xlsx_cutter <- function(

res <- lapply(
data_files,
single_xlsx_cutter,
template_file, data_sheet, coords, noms
function(f) {
tryCatch(
single_xlsx_cutter(f, template_file, data_sheet, coords, noms),
warning = function(c) NULL,
error = function(c) NULL
)
}
)

failed <- vapply(res, is.null, logical(1))

if (any(failed)) {
warning(
"parsing failed for ", sum(failed), " files:\n",
toString(data_files[failed])
)
}

res <- as.data.frame(do.call(rbind, res))

type.convert(res, as.is = TRUE)
Expand Down

0 comments on commit 9d55f69

Please sign in to comment.