如何使用R将空数据保存到ADLSGEN2?

发布于 2025-01-30 07:51:23 字数 70 浏览 5 评论 0原文

我已经探索过,但没有找到任何建议。 我想知道如何使用R将空文件保存到ADLSGEN2,然后将其读回相同的代码。 感谢您的帮助。

I've explored but didn't find any suggestions.
I want to know how to save an empty file to adlsgen2 using R and then read it back to the same code.
Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

家住魔仙堡 2025-02-06 07:51:23

由于您想使用R为ADLS GEN2编写一个空文件并从该位置读取它,因此首先创建一个数据框架。

  • 数据框可以是完全空的,也可以是具有列名但没有行的数据框。您可以使用以下代码来创建一个代码。
df <- data.frame()  #OR

df <- data.frame(<col_name>=<type>)  
  • 创建数据框后,您必须建立与ADLS Gen2帐户的连接。您可以使用以下链接中指定的方法来执行此操作。

https://saketbi.wordpress.com/2019/05/11/how-to-connect-connect-to-connect-to-adls-gen2-using-sparkr-from-databricks -rstudio-while-while-while-nile-nile-nile-with-with-with-key-key-key-keke-keke-建立

  • 连接后,您可以使用ADLS GEN2存储的路径使用r语言读取和写入函数。以下链接提供了许多可以根据您的要求使用的功能。

https://www.geeksforgeeks.orgs.org/reading-files-files-files-files-files-files-files-files-in-in-r-r-in-r-in-r-in-in--in--in-r-r-r - 编程/

Since you want to write an empty file to ADLS gen2 using R and read it from that location, first create a dataframe.

  • The dataframe can either be completely empty, or it can be a dataframe with column names but no rows. You can use the following code to create one.
df <- data.frame()  #OR

df <- data.frame(<col_name>=<type>)  
  • Once you have created a dataframe, you must establish connection to ADLS gen2 account. You can use the method specified in the following link to do that.

https://saketbi.wordpress.com/2019/05/11/how-to-connect-to-adls-gen2-using-sparkr-from-databricks-rstudio-while-integrating-securely-with-azure-key-vault/

  • After making the connection you can use read and write functions in R language using the path to ADLS gen2 storage. The following link provides numerous functions that can be used according to your requirement.

https://www.geeksforgeeks.org/reading-files-in-r-programming/

回忆那么伤 2025-02-06 07:51:23

分享我的问题的解决方案:

我使用SparkR创建一个空的数据框架并在设置Spark上下文后将其保存在ADL中。

解决方案如下:

步骤1:创建一个模式

fcstSchema <- structType(structField("ABC", "string",TRUE))

new_df<- data.frame(ABC=NULL,stringsAsFactors=FALSE)

n<-createDataFrame(new_df,fcstSchema)

SparkR::saveDF(n,path = "abfss://<account_name>@<datalake>.dfs.core.windows.net/<path>/",source = "delta",mode = "overwrite")

Sharing the solution to my question:

I've used SparkR to create an empty data frame and save the same in the adls after setting up the spark context.

Solution is below:

Step 1: Create a schema

fcstSchema <- structType(structField("ABC", "string",TRUE))

new_df<- data.frame(ABC=NULL,stringsAsFactors=FALSE)

n<-createDataFrame(new_df,fcstSchema)

SparkR::saveDF(n,path = "abfss://<account_name>@<datalake>.dfs.core.windows.net/<path>/",source = "delta",mode = "overwrite")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文