![](/img/trans.png)
[英]Write a csv file from R Notebook in Databricks to Azure blob storage?
[英]Access Azure blob storage from R notebook
在 python 中,這是我從 Azure blob 訪問 csv 的方式
storage_account_name = "testname"
storage_account_access_key = "..."
file_location = "wasb://example@testname.blob.core.windows.net/testfile.csv"
spark.conf.set(
"fs.azure.account.key."+storage_account_name+".blob.core.windows.net",
storage_account_access_key)
df = spark.read.format('csv').load(file_location, header = True, inferSchema = True)
我怎樣才能在 R 中做到這一點? 我找不到任何文件...
AzureStor包為 Azure 存儲提供 R 接口,包括文件、blob 和 ADLSgen2。
endp <- storage_endpoint("https://acctname.blob.core.windows.net", key="access_key")
cont <- storage_container(endp, "mycontainer")
storage_download(cont, "myblob.csv", "local_filename.csv")
請注意,這將下載到本地存儲中的文件。 從那里,您可以使用標准 Sparklyr 方法攝取到 Spark。
免責聲明:我是 AzureStor 的作者。
如果您不想下載它,請創建一個臨時文件,然后從中讀取
endp <- storage_endpoint("https://acctname.blob.core.windows.net", key="access_key")
cont <- storage_container(endp, "mycontainer")
fname <- tempfile()
storage_download(cont, "myblob.csv", fname)
df = read.csv(fname)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.