Skip to content

Commit

Permalink
Fix #315
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot committed Sep 13, 2023
1 parent 4a1f905 commit 3d91cd5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Imports:
curl (>= 0.6),
data.table (>= 1.11.2),
readxl (>= 0.1.1),
arrow (>= 0.17.0),
tibble,
stringi,
writexl,
Expand All @@ -60,7 +61,6 @@ Suggests:
testthat,
knitr,
magrittr,
arrow (>= 0.17.0),
clipr,
fst,
hexView,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `get_info` is added #350
* POTENTIALLY BREAKING: `setclass` parameter is now authoritative. Therefore: `import("starwars.csv", data.table = TRUE, setclass = "tibble")` will return a tibble (unlike previous versions where a data.table is returned). The default class is data frame. You can either explicitly use the `setclass` parameter; or set the option: `options(rio.import.class = "data.table")`. h/t David Schoch #336
* Use `writexl` instead of `openxlsx`. Option to read xlsx with `openxlsx` (i.e. `import("starwars.xlsx", readxl = FALSE)`) is always `TRUE`. The ability to overwrite an existing sheet in an existing xlsx file is also removed. It is against the design principle of `rio`.
* Parquet and feather are now formats supported out of the box #315
* POTENTIALLY BREAKING: The following options are deprecated: `import(fread)`, `import(readr = TRUE)`, `import(haven)`, `import(readxl)` and `export(fwrite)`. import will almost use `data.table`, `haven`, `readxl`, and internal function (for fwf) to import and export data. Currently, those options stay for backward compatibility but will be removed in v2.0.0. #343 h/t David Schoch
* POTENTIALLY BREAKING: `...` is handled differently. Underlying functions using "Tidy" convention (e.g. `readxl::read_xlsx()`) can use "Base Convention" (See the new vignette: `remap`). Unused arguments passed to the underlying function as `...` are silently ignored by default. A new option `rio.ignoreunusedargs` is added to control this behavior. #326
* Bug fixes
Expand Down
2 changes: 0 additions & 2 deletions R/export_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export_delim <- function(file, x, fwrite = lifecycle::deprecated(), sep = "\t",

#' @export
.export.rio_feather <- function(file, x, ...) {
.check_pkg_availability("arrow")
arrow::write_feather(x = x, sink = file, ...)
}

Expand Down Expand Up @@ -286,7 +285,6 @@ export_delim <- function(file, x, fwrite = lifecycle::deprecated(), sep = "\t",

#' @export
.export.rio_parquet <- function(file, x, ...) {
.check_pkg_availability("arrow")
arrow::write_parquet(x = x, sink = file, ...)
}

Expand Down
2 changes: 0 additions & 2 deletions R/import_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings

#' @export
.import.rio_feather <- function(file, which = 1, ...) {
.check_pkg_availability("feather")
arrow::read_feather(file = file, ...)
}

Expand Down Expand Up @@ -390,7 +389,6 @@ extract_html_row <- function(x, empty_value) {

#' @export
.import.rio_parquet <- function(file, which = 1, as_data_frame = TRUE, ...) {
.check_pkg_availability("arrow")
arrow::read_parquet(file = file, as_data_frame = TRUE, ...)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_format_csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ test_that("Import from (European-style) CSV with semicolon separator", {
write.table(iris, "iris2.csv", dec = ",", sep = ";", row.names = FALSE)
expect_true("iris2.csv" %in% dir())
# import works (even if column classes are incorrect)
expect_true(is.data.frame(import("iris2.csv", fread = TRUE, header = TRUE)))
iris_imported <- import("iris2.csv", format = ";", fread = TRUE, header = TRUE)
expect_true(is.data.frame(import("iris2.csv", header = TRUE)))
iris_imported <- import("iris2.csv", format = ";", header = TRUE)
# import works with correct, numeric column classes
expect_true(is.data.frame(iris_imported))
expect_true(is.numeric(iris_imported[["Sepal.Length"]]))
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test_format_feather.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ context("feather imports/exports")
require("datasets")

test_that("Export to feather", {
skip_if_not_installed(pkg="feather")
expect_true(export(iris, "iris.feather") %in% dir())
})

test_that("Import from feather", {
skip_if_not_installed(pkg="feather")
expect_true(is.data.frame(import("iris.feather")))
})

test_that("... correctly passed, #318", {
skip_if_not_installed(pkg="feather")
## actually feather::write_feather has only two arguments (as of 2023-09-01)
## it is more for possible future expansion
expect_error(export(mtcars, "mtcars.feather", hello = 42))
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test_format_parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ context("Parquet imports/exports")
require("datasets")

test_that("Export to and import from parquet", {
skip_if_not_installed("arrow")
expect_true(export(iris, "iris.parquet") %in% dir())
expect_true(is.data.frame(import("iris.parquet")))
unlink("iris.parquet")
Expand Down

0 comments on commit 3d91cd5

Please sign in to comment.