diff --git a/NEWS.md b/NEWS.md index ba21a1f2a..1bbd7a935 100644 --- a/NEWS.md +++ b/NEWS.md @@ -33,6 +33,8 @@ `upper_bound` (#1203). - `$clip_min()` and `$clip_max()` are removed. Use `$clip()` with only `lower_bound` or `upper_bound` instead (#1203). +- In `$write_csv` and `$sink_csv()`, the argument `quote` is renamed + `quote_char` (#1206). ### New features diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index ab45a516e..d54545d8a 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -1900,7 +1900,7 @@ DataFrame_transpose = function( #' @param include_header Whether to include header in the CSV output. #' @param separator Separate CSV fields with this symbol. #' @param line_terminator String used to end each row. -#' @param quote Byte to use as quoting character. +#' @param quote_char Byte to use as quoting character. #' @param batch_size Number of rows that will be processed per thread. #' @param datetime_format A format string, with the specifiers defined by the #' chrono Rust crate. If no format specified, the default fractional-second @@ -1945,7 +1945,7 @@ DataFrame_write_csv = function( include_header = TRUE, separator = ",", line_terminator = "\n", - quote = '"', + quote_char = '"', batch_size = 1024, datetime_format = NULL, date_format = NULL, @@ -1955,7 +1955,7 @@ DataFrame_write_csv = function( quote_style = "necessary") { .pr$DataFrame$write_csv( self, - file, include_bom, include_header, separator, line_terminator, quote, + file, include_bom, include_header, separator, line_terminator, quote_char, batch_size, datetime_format, date_format, time_format, float_precision, null_values, quote_style ) |> diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 4fb3f99a9..d3a1b55cd 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -220,7 +220,7 @@ RPolarsDataFrame$transpose <- function(keep_names_as, new_col_names) .Call(wrap_ RPolarsDataFrame$clear <- function() .Call(wrap__RPolarsDataFrame__clear, self) -RPolarsDataFrame$write_csv <- function(file, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__RPolarsDataFrame__write_csv, self, file, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) +RPolarsDataFrame$write_csv <- function(file, include_bom, include_header, separator, line_terminator, quote_char, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__RPolarsDataFrame__write_csv, self, file, include_bom, include_header, separator, line_terminator, quote_char, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) RPolarsDataFrame$write_ipc <- function(file, compression, compat_level) .Call(wrap__RPolarsDataFrame__write_ipc, self, file, compression, compat_level) @@ -1194,7 +1194,7 @@ RPolarsLazyFrame$sink_parquet <- function(path, compression_method, compression_ RPolarsLazyFrame$sink_ipc <- function(path, compression, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_ipc, self, path, compression, maintain_order) -RPolarsLazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) +RPolarsLazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote_char, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote_char, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) RPolarsLazyFrame$sink_json <- function(path, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_json, self, path, maintain_order) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 312721688..2d2839a7f 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -837,7 +837,7 @@ LazyFrame_sink_csv = function( include_header = TRUE, separator = ",", line_terminator = "\n", - quote = '"', + quote_char = '"', batch_size = 1024, datetime_format = NULL, date_format = NULL, @@ -880,7 +880,7 @@ LazyFrame_sink_csv = function( include_header, separator, line_terminator, - quote, + quote_char, batch_size, datetime_format, date_format, diff --git a/man/IO_sink_csv.Rd b/man/IO_sink_csv.Rd index e39dc4344..e702a5588 100644 --- a/man/IO_sink_csv.Rd +++ b/man/IO_sink_csv.Rd @@ -11,7 +11,7 @@ LazyFrame_sink_csv( include_header = TRUE, separator = ",", line_terminator = "\\n", - quote = "\\"", + quote_char = "\\"", batch_size = 1024, datetime_format = NULL, date_format = NULL, @@ -42,7 +42,7 @@ output.} \item{line_terminator}{String used to end each row.} -\item{quote}{Byte to use as quoting character.} +\item{quote_char}{Byte to use as quoting character.} \item{batch_size}{Number of rows that will be processed per thread.} diff --git a/man/IO_write_csv.Rd b/man/IO_write_csv.Rd index 421883a14..d1268e8c2 100644 --- a/man/IO_write_csv.Rd +++ b/man/IO_write_csv.Rd @@ -11,7 +11,7 @@ DataFrame_write_csv( include_header = TRUE, separator = ",", line_terminator = "\\n", - quote = "\\"", + quote_char = "\\"", batch_size = 1024, datetime_format = NULL, date_format = NULL, @@ -35,7 +35,7 @@ output.} \item{line_terminator}{String used to end each row.} -\item{quote}{Byte to use as quoting character.} +\item{quote_char}{Byte to use as quoting character.} \item{batch_size}{Number of rows that will be processed per thread.} diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index e0dfa4f84..483d04642 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -144,7 +144,7 @@ impl RPolarsLazyFrame { include_header: Robj, separator: Robj, line_terminator: Robj, - quote: Robj, + quote_char: Robj, batch_size: Robj, datetime_format: Robj, date_format: Robj, @@ -160,7 +160,7 @@ impl RPolarsLazyFrame { let datetime_format = robj_to!(Option, String, datetime_format)?; let float_precision = robj_to!(Option, usize, float_precision)?; let separator = robj_to!(Utf8Byte, separator)?; - let quote = robj_to!(Utf8Byte, quote)?; + let quote_char = robj_to!(Utf8Byte, quote_char)?; let null_value = robj_to!(String, null_value)?; let line_terminator = robj_to!(String, line_terminator)?; let quote_style = robj_to!(QuoteStyle, quote_style)?; @@ -176,7 +176,7 @@ impl RPolarsLazyFrame { float_scientific: None, float_precision, separator, - quote_char: quote, + quote_char: quote_char, null: null_value, line_terminator, quote_style, diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index d76533c38..0f1d24062 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -495,7 +495,7 @@ impl RPolarsDataFrame { include_header: Robj, separator: Robj, line_terminator: Robj, - quote: Robj, + quote_char: Robj, batch_size: Robj, datetime_format: Robj, date_format: Robj, @@ -511,7 +511,7 @@ impl RPolarsDataFrame { .include_header(robj_to!(bool, include_header)?) .with_separator(robj_to!(Utf8Byte, separator)?) .with_line_terminator(robj_to!(String, line_terminator)?) - .with_quote_char(robj_to!(Utf8Byte, quote)?) + .with_quote_char(robj_to!(Utf8Byte, quote_char)?) .with_batch_size(robj_to!(nonzero_usize, batch_size)?) .with_datetime_format(robj_to!(Option, String, datetime_format)?) .with_date_format(robj_to!(Option, String, date_format)?) diff --git a/tests/testthat/test-csv-write.R b/tests/testthat/test-csv-write.R index 252fb791d..b05dc337d 100644 --- a/tests/testthat/test-csv-write.R +++ b/tests/testthat/test-csv-write.R @@ -45,15 +45,15 @@ test_that("write_csv: quote_style and quote works", { expect_identical(ctx$TypeMismatch, "&str") # zero byte quote - ctx = dat_pl2$write_csv(temp_out, quote = "") |> get_err_ctx() + ctx = dat_pl2$write_csv(temp_out, quote_char = "") |> get_err_ctx() expect_identical(ctx$Plain, "cannot extract single byte from empty string") # multi byte quote not allowed - ctx = dat_pl2$write_csv(temp_out, quote = "£") |> get_err_ctx() + ctx = dat_pl2$write_csv(temp_out, quote_char = "£") |> get_err_ctx() expect_identical(ctx$Plain, "multi byte-string not allowed") # multi string not allowed - ctx = dat_pl2$write_csv(temp_out, quote = c("a", "b")) |> get_err_ctx() + ctx = dat_pl2$write_csv(temp_out, quote_char = c("a", "b")) |> get_err_ctx() expect_identical(ctx$TypeMismatch, "&str") }) diff --git a/tests/testthat/test-sink_stream.R b/tests/testthat/test-sink_stream.R index 5d676c6df..9427ab15a 100644 --- a/tests/testthat/test-sink_stream.R +++ b/tests/testthat/test-sink_stream.R @@ -171,15 +171,15 @@ test_that("sink_csv: quote_style and quote works", { expect_identical(ctx$TypeMismatch, "&str") # zero byte quote - ctx = dat_pl2$sink_csv(temp_out, quote = "") |> get_err_ctx() + ctx = dat_pl2$sink_csv(temp_out, quote_char = "") |> get_err_ctx() expect_identical(ctx$Plain, "cannot extract single byte from empty string") # multi byte quote not allowed - ctx = dat_pl2$sink_csv(temp_out, quote = "£") |> get_err_ctx() + ctx = dat_pl2$sink_csv(temp_out, quote_char = "£") |> get_err_ctx() expect_identical(ctx$Plain, "multi byte-string not allowed") # multi string not allowed - ctx = dat_pl2$sink_csv(temp_out, quote = c("a", "b")) |> get_err_ctx() + ctx = dat_pl2$sink_csv(temp_out, quote_char = c("a", "b")) |> get_err_ctx() expect_identical(ctx$TypeMismatch, "&str") })