Skip to content

Commit

Permalink
add error trapping to flatfile_read()
Browse files Browse the repository at this point in the history
  • Loading branch information
btupper committed Apr 12, 2024
1 parent a0acb1a commit 5f1f557
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/gb-setup-tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5f1f557

Please sign in to comment.