Last active
May 19, 2020 20:37
-
-
Save davidtedfordholt/0e6650e1da20ad064bbcbd6d5e8d23ba to your computer and use it in GitHub Desktop.
copy dataset to CSV in google storage using cloudml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy_to_gcp <- function(.data, filename_prefix, gcp_folder = NULL, gcp_bucket) { | |
if (!startsWith(gcp_bucket, "gs://")) { | |
gcp_bucket <- paste0("gs://", gcp_bucket) | |
} | |
source <- paste0(filename_prefix, "_", format(Sys.Date(), "%Y%m%d"), ".csv") | |
destination <- ifelse(is.null(gcp_folder), gcp_bucket, paste0(gcp_bucket, "/", gcp_folder)) | |
packageStartupMessage("Writing file") | |
write.csv(.data, source) | |
packageStartupMessage("Copying file") | |
cloudml::gs_copy(source, destination) | |
packageStartupMessage("Removing file") | |
file.remove(source) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment