-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add excel serializer/parser #975
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just missing tests for the serializer and parser
Feel free to duplicate how parquet approached them:
plumber/tests/testthat/test-parse-body.R
Lines 112 to 135 in f4230ed
test_that("Test parquet parser", { skip_if_not_installed("arrow") tmp <- tempfile() on.exit({ file.remove(tmp) }, add = TRUE) r_object <- iris res <- try(arrow::write_parquet(r_object, tmp)) skip_if( inherits(res, "try-error"), "arrow::write_parquet() isn't working." ) val <- readBin(tmp, "raw", 10000) parsed <- parse_body(val, "application/vnd.apache.parquet", make_parser("parquet")) # convert from parquet tibble to data.frame parsed <- as.data.frame(parsed, stringsAsFactors = FALSE) attr(parsed, "spec") <- NULL expect_equal(parsed, r_object) }) - https://github.com/rstudio/plumber/blob/f4230ed45fa67d57179a901976245687427559d2/tests/testthat/test-serializer-feather.R
Thank you!
@@ -588,6 +620,7 @@ register_parsers_onLoad <- function() { | |||
register_parser("rds", parser_rds, fixed = "application/rds") | |||
register_parser("feather", parser_feather, fixed = c("application/vnd.apache.arrow.file", "application/feather")) | |||
register_parser("parquet", parser_parquet, fixed = "application/vnd.apache.parquet") | |||
register_parser("excel", parser_excel, fixed = c("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-excel")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified mime types from https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
call. = FALSE) | ||
} | ||
|
||
serializer_write_file( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes for me... writexl::write_xlsx()
can not leverage the changes in #972 as write_xl is expecting a file string and does not return a raw vector here: https://github.com/ropensci/writexl/blob/7c06c338cdddc0cc1c078afe3173a71a6efe33ff/src/write_xlsx.c#L209
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bummer
You can't see the uncommitted new-file |
@schloerke should be good now, tests are confirmed committed, |
Fixes #973
Fixes #959
PR task list:
devtools::document()