thisisnic commented on code in PR #33614: URL: https://github.com/apache/arrow/pull/33614#discussion_r1072268189
########## r/R/dataset.R: ########## @@ -228,6 +228,131 @@ open_dataset <- function(sources, ) } +#' Open a multi-file dataset of CSV or other delimiter-separated format +#' +#' A wrapper around [open_dataset] which explicitly includes parameters mirroring [read_csv_arrow()], +#' [read_delim_arrow()], and [read_tsv_arrow()] to allows for easy switching between functions +#' for opening single files and functions for opening datasets. +#' +#' @inheritParams open_dataset +#' @inheritParams read_delim_arrow +#' +#' @section Options currently supported by [read_delim_arrow()] which are not supported here: +#' * `file` (instead, please specify files in `sources`) +#' * `col_select` (instead, subset columns after dataset creation) +#' * `quoted_na` +#' * `as_data_frame` (instead, convert to data frame after dataset creation) +#' * `parse_options` +#' +#' @examplesIf arrow_with_dataset() +#' # Set up directory for examples +#' tf <- tempfile() +#' dir.create(tf) +#' on.exit(unlink(tf)) +#' df <- data.frame(x = c("1", "2", "NULL")) +#' +#' file_path <- file.path(tf, "file1.txt") +#' write.table(df, file_path, sep = ",", row.names = FALSE) +#' +#' read_csv_arrow(file_path, na = c("", "NA", "NULL"), col_names = "y", skip = 1) +#' open_csv_dataset(file_path, na = c("", "NA", "NULL"), col_names = "y", skip = 1) +#' +#' @seealso [open_dataset()] +#' @export +open_delim_dataset <- function(sources, + schema = NULL, + partitioning = hive_partition(), + hive_style = NA, + unify_schemas = NULL, + factory_options = list(), + delim = ",", + quote = "\"", + escape_double = TRUE, + escape_backslash = FALSE, + col_names = TRUE, + col_types = NULL, + na = c("", "NA"), + skip_empty_rows = TRUE, + skip = 0L, + convert_options = NULL, + read_options = NULL, + timestamp_parsers = NULL) { + + open_dataset( + sources = sources, + schema = schema, + partitioning = partitioning, + hive_style = hive_style, + unify_schemas = unify_schemas, + factory_options = factory_options, + format = "text", + delim = delim, + quote = quote, + escape_double = escape_double, + escape_backslash = escape_backslash, + col_names = col_names, + col_types = col_types, + na = na, + skip_empty_rows = skip_empty_rows, + skip = skip, + convert_options = convert_options, + read_options = read_options, + timestamp_parsers = timestamp_parsers + ) +} + +#' @rdname open_delim_dataset +#' @export +open_csv_dataset <- function(sources, + schema = NULL, + partitioning = hive_partition(), + hive_style = NA, + unify_schemas = NULL, + factory_options = list(), + quote = "\"", + escape_double = TRUE, + escape_backslash = FALSE, + col_names = TRUE, + col_types = NULL, + na = c("", "NA"), + skip_empty_rows = TRUE, + skip = 0L, + convert_options = NULL, + read_options = NULL, + timestamp_parsers = NULL) { + mc <- match.call() + mc$delim <- "," + mc[[1]] <- get("open_delim_dataset", envir = asNamespace("arrow")) + eval.parent(mc) Review Comment: Actually, no, I don't want the `open_csv_dataset()` function to take ellipses as its arguments. Part of the point of this wrapper is to have explicitly documented parameters. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org