如何将R数据帧写入Google Cloud Storage存储桶文件夹

编程入门 行业动态 更新时间:2024-10-09 12:31:16
本文介绍了如何将R数据帧写入Google Cloud Storage存储桶文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将R数据帧写入Google Cloud Storage存储桶.我在R中使用googleCloudStorageR库,这是我的代码-

I want to write R dataframe to Google Cloud Storage bucket. I am using googleCloudStorageR library in R and here is my code -

################### START ############################### options(googleAuthR.scopes.selected = "www.googleapis/auth/cloud-platform") # load the libraries library("googleAuthR", lib.loc="/home/user/packages" ) library("googleCloudStorageR", lib.loc="/home/user/packages") gar_gce_auth() name <- c("john","doe") id <- c(1,2) results = as.data.frame(cbind(name,id)) print("writing results to GCS") # Set bucket name bucket <- "my-bucket" gcs_global_bucket(bucket) print("bucket set.") # Upload that file to the global bucket gcs_upload(file = results , name = "results.csv") ################## END ################################

这会将数据帧加载到存储区my-bucket中.

This loads the dataframe to bucket my-bucket.

现在,我想保存相同的数据帧,但是保存到不同的文件夹结构中,例如-my-bucket\my-folder\results.csv.如何将数据框保存到GCS中的此新路径?

Now I want to save this same dataframe but to a different folder structure, for example - my-bucket\my-folder\results.csv . How can I save the dataframe to this new path in GCS ?

cran.r-project/web /packages/googleCloudStorageR/googleCloudStorageR.pdf

推荐答案

您将名称更改为文件夹结构(unix样式),因此更改了最后一行:

You change the name to be your folder structure (unix style), so change the last line:

# Upload that file to the global bucket gcs_upload(file = results , name = "my-folder/results.csv")

更多推荐

如何将R数据帧写入Google Cloud Storage存储桶文件夹

本文发布于:2023-11-24 14:03:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625514.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   文件夹   数据   Google   Cloud

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!