![](/img/trans.png)
[英]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.