简体   繁体   English

使用 Python 从 azure blob 存储下载文件(csv、excel)

[英]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.

相关问题 如何使用 Python 从给定 SAS URI 和容器名称的 Azure Blob 存储下载文件列表? - How to download a list of files from Azure Blob Storage given SAS URI and container name using Python? 使用 python azure 函数从 azure blob 存储读取文件 - Read files from azure blob storage using python azure functions 使用 Python 从 Blob 存储下载 Blob - Download Blob From Blob Storage Using Python 使用适用于 Python 的 Azure 存储 SDK 将多个文件从文件夹上传到 Azure Blob 存储 - Upload multiple files from folder to Azure Blob storage using Azure Storage SDK for Python 将 csv 个文件从 azure blob 存储 A 复制到 azure blob 存储 B - copy csv files from azure blob storage A to azure blob storage B 从“输入”blob 存储容器中读取 excel 文件,并使用 python 导出到“输出”容器中的 csv - Reading excel files from "input" blob storage container and exporting to csv in "output" container with python 如何使用 PowerShell 或 python 脚本读取然后编辑或附加存储在 Azure Blob 存储中的 Excel 文件(列和行) - How to read then edit or append an Excel Files (columns and rows ) stored in Azure Blob Storage using PowerShell or python script 使用 Databricks PySpark 从 Azure blob 存储读取多个 CSV 文件 - Reading multiple CSV files from Azure blob storage using Databricks PySpark 使用 python 创建 csv 文件并将其上传到 azure blob 存储 - Create and upload csv file to azure blob storage using python 使用python上载csv文件以使Blob存储蔚蓝 - Uploading csv file using python to azure blob storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM