Skip to content

Commit

Permalink
Update tibble::data_frame references to tibble::tibble (#1124)
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Hester <james.f.hester@gmail.com>
  • Loading branch information
brianrice2 and jimhester authored Sep 14, 2020
1 parent 1fc4137 commit b01ae1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@

* New `%h` placeholder for parsing unrestricted hours (<0 and >23) to support parsing durations (#549, @krlmlr).

* Uses of `tibble::data_frame` updated to `tibble::tibble`
([tidyverse/dplyr#4069](https://github.com/tidyverse/dplyr/issues/4069),
@thays42)
* Uses of `tibble::data_frame` updated to `tibble::tibble` ([tidyverse/dplyr#4069](https://github.com/tidyverse/dplyr/issues/4069), @thays42, #1124, @brianrice2)

* `read_delimited()` function return an empty `tibble::data_frame()` rather
than signaling an error when given a connection for the `file` argument that
Expand Down
4 changes: 2 additions & 2 deletions R/read_delim.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ read_delimited <- function(file, tokenizer, col_names = TRUE, col_types = NULL,
if (is.connection(file)) {
data <- datasource_connection(file, skip, skip_empty_rows, comment)
if (empty_file(data[[1]])) {
return(tibble::data_frame())
return(tibble::tibble())
}
} else {
if (!isTRUE(grepl("\n", file)[[1]]) && empty_file(file)) {
return(tibble::tibble())
}
if (is.character(file) && identical(locale$encoding, "UTF-8")) {
# When locale is not set, file is probablly marked as its correct encoding.
# When locale is not set, file is probably marked as its correct encoding.
# As default_locale() assumes file is UTF-8, file should be encoded as UTF-8 for non-UTF-8 MBCS locales.
data <- enc2utf8(file)
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-read-csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ test_that("empty file with col_names and col_types creates correct columns", {
expect_equal(class(x$b), "integer")
})

test_that("empty file returns an empty tibble", {
file.create("foo.csv")
expect_equal(read_csv("foo.csv"), tibble::tibble())
file.remove("foo.csv")
})


# Comments ----------------------------------------------------------------

Expand Down

0 comments on commit b01ae1e

Please sign in to comment.