From 5f1f55760965c84961d7004c995c4a756b8c9a27 Mon Sep 17 00:00:00 2001 From: Ben Tupper Date: Fri, 12 Apr 2024 09:50:20 -0400 Subject: [PATCH] add error trapping to flatfile_read() --- R/gb-setup-tools.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/gb-setup-tools.R b/R/gb-setup-tools.R index 8c1741c..2b29326 100644 --- a/R/gb-setup-tools.R +++ b/R/gb-setup-tools.R @@ -7,7 +7,12 @@ flatfile_read <- function(flpth) { generate_records <- function(i) { indexes <- record_starts[i]:record_ends[i] - record <- paste0(lines[indexes], collapse = '\n') + record <- try(paste0(lines[indexes], collapse = '\n')) + if (inherits(record, "try-error")){ + print(record) + warning("record too long, dropping") + record = NULL + } record } connection <- file(flpth, open = "r")