[英]How to read parquet file from Azure Python function blob input binding?
[英]How to read parquet file into pandas from Azure blob store
我需要在运行 Python 3 kernel 的 Jupyter 笔记本的上下文中从 Azure blob 存储读取和写入镶木地板文件。
我看到了严格使用镶木地板文件和 python 以及其他用于抓取/写入 Azure blob 存储的代码的代码,但还没有将它们放在一起。
这是我正在玩的一些示例代码:
from azure.storage.blob import BlockBlobService block_blob_service = BlockBlobService(account_name='testdata', account_key='key-here') block_blob_service.get_blob_to_text(container_name='mycontainer', blob_name='testdata.parquet')
最后一行抛出与编码相关的错误。 我玩过storefact但在那里做不到。
谢谢你的帮助
要访问该文件,您需要先访问 azure blob 存储。
storage_account_name = "your storage account name"
storage_account_access_key = "your storage account access key"
将镶木地板文件的路径读入变量
commonLOB_mst_source = "Parquet file path"
file_type = "parquet"
连接到 Blob 存储
spark.conf.set(
"fs.azure.account.key."+storage_account_name+".blob.core.windows.net",
storage_account_access_key)
将 Parquet 文件读入 dataframe
df = spark.read.format(file_type).option("inferSchema", "true").load(commonLOB_mst_source)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.