Skip to content

Commit

Permalink
Explicitly name stream_in arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Sep 14, 2016
1 parent f44f3a2 commit a648bce
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions R/stream.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,25 @@ stream_in <- function(con, handler = NULL, pagesize = 500, verbose = TRUE, ...)

# Either return a big data frame, or nothing.
if(is.null(handler)){
if(verbose) cat("\r Imported", count, "records. Simplifying into dataframe...\n")
if(verbose) cat("\r Imported", count, "records. Simplifying...\n")
out <- as.list(out, sorted = FALSE)
post_process(unlist(out[order(as.numeric(names(out)))], FALSE, FALSE), ...)
} else {
invisible()
}
}

post_process <- function(x, ...){
as.data.frame(simplify(x, ...))
post_process <- function(x, simplifyVector = TRUE, simplifyDataFrame = simplifyVector,
simplifyMatrix = simplifyVector, flatten = FALSE){
out <- simplify(x, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame,
simplifyMatrix = simplifyMatrix, flatten = flatten)

# We assume ndjson with objects
if(isTRUE(simplifyDataFrame)){
return(as.data.frame(out))
} else {
out
}
}

#' @rdname stream_in
Expand Down

0 comments on commit a648bce

Please sign in to comment.