从R笔记本访问Azure Blob存储 [英] Access Azure blob storage from R notebook

查看:116
本文介绍了从R笔记本访问Azure Blob存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在python中,这是我如何从Azure blob访问CSV

in python this is how I would access a csv from Azure blobs

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中做到这一点?我找不到任何文档...

How can I do this in R? I cannot find any documentation...

推荐答案

AzureStor 程序包为Azure存储提供了R接口,包括文件,blob和ADLSgen2.

The AzureStor package provides an R interface to Azure storage, including files, blobs and 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.

Note that this will download to a file in local storage. From there, you can ingest into Spark using standard Sparklyr methods.

免责声明:我是AzureStor的作者.

Disclaimer: I'm the author of AzureStor.

这篇关于从R笔记本访问Azure Blob存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆