通过 Azure notebook 从 blob 容器访问 csv 文件

Accessing csv file from blob container through Azure notebook

我想使用 Azure Python 笔记本从 blob 存储中的容器访问一个大小约为 2GB 的文件,但由于某种原因我遇到了这个错误。

权限错误:[Errno 13] 权限被拒绝:'part-00000-tid-9128541598398997257-8ae9f3ab-ad94-4ed6-ac2d-91b488393378-72-1-c000.csv'

Here is the snippet of code that worked for me before, but for some reason is not working now

我已经添加了存储帐户 url,它对我有用。 这是供您参考的代码

from azure.storage.blob import BlobServiceClient
import pandas as pd

STORAGEACCOUNTNAME= "<Storage account Name>"
STORAGEACCOUNTKEY= "<Storage account key>"
LOCALFILENAME= "<Local file name>"
CONTAINERNAME= "<Container name>"
BLOBNAME= "<blob name>"
STORAGEACCOUNTURL="https://<storage account name>.blob.core.windows.net"

#To download the blob
blob_service_client_instance = BlobServiceClient(account_url=STORAGEACCOUNTURL, credential=STORAGEACCOUNTKEY)
blob_client_instance = blob_service_client_instance.get_blob_client(CONTAINERNAME, BLOBNAME, snapshot=None)
with open(LOCALFILENAME, "wb") as my_blob:
    blob_data = blob_client_instance.download_blob()
    blob_data.readinto(my_blob)

#Read the blob
dataframe_blobdata = pd.read_csv(LOCALFILENAME)
print(dataframe_blobdata)

这是输出

参考资料: Explore data in Azure Blob storage with pandas - Team Data Science Process - Azure Architecture Center | Microsoft Docs