Skip to content

Commit

Permalink
change erroneous imports to use json instead of ndjson
Browse files Browse the repository at this point in the history
  • Loading branch information
rfhb committed Nov 10, 2024
1 parent 60eeb27 commit d324b59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions R/util_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1308,15 +1308,12 @@ dbCTRLoadJSONFiles <- function(dir, con, verbose) {

# step into line by line mode
fdLines <- file(tempFiles[tempFile], open = "rt", blocking = TRUE)
fLineOut <- tempfile(pattern = "tmpOneLine", tmpdir = dir, fileext = ".ndjson")
on.exit(unlink(fLineOut), add = TRUE)
while (TRUE) {
tmpOneLine <- readLines(con = fdLines, n = 1L, warn = FALSE)
if (length(tmpOneLine) == 0L || !nchar(tmpOneLine)) break
id <- sub(".*\"_id\":[ ]*\"(.*?)\".*", "\\1", tmpOneLine)
cat(tmpOneLine, file = fLineOut)
tmp <- suppressWarnings(suppressMessages(nodbi::docdb_create(
src = con, key = con$collection, value = fLineOut)))
src = con, key = con$collection, value = paste0("[", tmpOneLine, "]"))))
nImported <- nImported + tmp
if (tmp) idSuccess <- c(idSuccess, id)
if (!tmp) idFailed <- c(idFailed, id)
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_ctrdata_other_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ dF <- data.frame(
dL <- suppressMessages(
dfTrials2Long(dF)
)

dL2 <- dfTrials2Long(
df = dF[, 4:1]
)
Expand Down Expand Up @@ -503,3 +502,4 @@ expect_true(

# cleanup
rm(dF, dL)

0 comments on commit d324b59

Please sign in to comment.