-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
BigQuery expects strings to be quoted in the "usual" manner, meaning that quotes in string fields should be doubled, with the field itself in quotes. This accomplishes this by tweaking arguments to `encodeString` and `write.table`, and (unfortunately) quotes all string fields as a side-effect.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ standard_csv <- function(values) { | |
|
||
# Encode special characters in strings | ||
is_char <- vapply(values, is.character, logical(1)) | ||
values[is_char] <- lapply(values[is_char], encodeString, na.encode = FALSE, quote = '"') | ||
values[is_char] <- lapply(values[is_char], encodeString, na.encode = FALSE) | ||
|
||
# Encode dates and times | ||
is_time <- vapply(values, function(x) inherits(x, "POSIXct"), logical(1)) | ||
|
@@ -84,7 +84,7 @@ standard_csv <- function(values) { | |
values[is_date] <- lapply(values[is_date], function(x) as.numeric(as.POSIXct(x))) | ||
|
||
tmp <- tempfile(fileext = ".csv") | ||
write.table(values, tmp, sep = ",", quote = FALSE, qmethod = "escape", | ||
write.table(values, tmp, sep = ",", quote = TRUE, qmethod = "double", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
craigcitro
Author
Owner
|
||
row.names = FALSE, col.names = FALSE, na = "") | ||
|
||
# Don't read trailing nl | ||
|
Are you sure you need
quote = TRUE
here?