[英]Download files (csv, excel) from azure blob storage using Python
I am trying to download the files (csv, excel) from blob storage in Python using the below code.我正在尝试使用以下代码从 Python 中的 blob 存储下载文件(csv、excel)。
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
blob_service_client = BlobServiceClient.from_connection_string(AZURE_STORAGE_CONNECTION_STRING)
container_client = blob_service_client.get_container_client(CONTAINER_NAME)
blob_client = container_client.get_blob_client('test12345.csv')
with open("test12345.csv", "wb") as f:
data = blob_client.download_blob()
data.readinto(f)'''
I am able to download the files, but the downloaded files are stored in byte data.我可以下载文件,但下载的文件存储在字节数据中。 Could anyone please help.
谁能帮忙。 Thank you!
谢谢!
If I am wrong, the implementation is slightly wrong in the last line of your snippet.如果我错了,则代码段最后一行的实现略有错误。 You could use the below code:
您可以使用以下代码:
f.write(data.readall())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.