Skip to content

Commit

Permalink
Add early check for connections with empty data
Browse files Browse the repository at this point in the history
Fixes #963
  • Loading branch information
pralitp authored and jimhester committed Feb 11, 2019
1 parent 5e7a2b9 commit 34fa25a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# readr (development version)

* `read_delimited()` function return an empty `tibble::data_frame()` rather
than signaling an error when given a connection for the `file` argument that
contains no data. This makes the behavior consistent as when called with an
empty file (@pralitp, #963).

# readr 1.3.1

* Column specifications are now coloured when printed. This makes it easy to
Expand Down
3 changes: 3 additions & 0 deletions R/read_delim.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ read_delimited <- function(file, tokenizer, col_names = TRUE, col_types = NULL,
file <- standardise_path(file)
if (is.connection(file)) {
data <- datasource_connection(file, skip, skip_empty_rows, comment)
if (empty_file(data[[1]])) {
return(tibble::data_frame())
}
} else {
if (empty_file(file)) {
return(tibble::data_frame())
Expand Down

0 comments on commit 34fa25a

Please sign in to comment.