dgreiss commented on code in PR #36436:
URL: https://github.com/apache/arrow/pull/36436#discussion_r1284707937


##########
r/R/csv.R:
##########
@@ -510,32 +510,55 @@ CsvReadOptions$create <- function(use_threads = 
option_use_threads(),
   options
 }
 
-readr_to_csv_write_options <- function(include_header = TRUE,
+readr_to_csv_write_options <- function(col_names = TRUE,
                                        batch_size = 1024L,
-                                       na = "") {
+                                       delim = ",",
+                                       na = "",
+                                       eol = "\n",
+                                       quote = "Needed") {

Review Comment:
   I think it's cleaner to only support the Arrow version, otherwise you need 
to validate and support both options:
   
   ```r
   write_dataset(ds, path, quote = "Needed")
   
   write_delim_dateset(ds, path, quote = "needed")
   ```
   
   Also, I'm not sure the behaviour of the `needed` options are identical. 
Specifically Arrow only encloses for quotes, whereas readr encloses for a 
delimiter, quote, or newline. The arrow options are 
[here](https://github.com/apache/arrow/blob/9b3bf08f78f690605394ad3815177ece931f06d3/cpp/src/arrow/csv/options.h#L173-L186):
 
   
   ```c++
   /// \brief Quoting style for CSV writing
   enum class ARROW_EXPORT QuotingStyle {
     /// Only enclose values in quotes which need them, because their CSV 
rendering can
     /// contain quotes itself (e.g. strings or binary values)
     Needed,
     /// Enclose all valid values in quotes. Nulls are not quoted. May cause 
readers to
     /// interpret all values as strings if schema is inferred.
     AllValid,
     /// Do not enclose any values in quotes. Prevents values from containing 
quotes ("),
     /// cell delimiters (,) or line endings (\\r, \\n), (following RFC4180). 
If values
     /// contain these characters, an error is caused when attempting to write.
     None
   };
   
   ```
   
   The `readr::write_*` options for `quote` 
[are](https://readr.tidyverse.org/reference/write_delim.html): 
   
   * needed - Values are only quoted if needed: if they contain a delimiter, 
quote, or newline.
   * all - Quote all fields.
   * none - Never quote fields.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to