使用 python 将 CSV 文件上传到 Microsoft Azure 存储帐户

编程入门 行业动态 更新时间:2024-10-28 06:30:26
本文介绍了使用 python 将 CSV 文件上传到 Microsoft Azure 存储帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 python 将 .csv 文件上传到 Microsoft Azure 存储帐户.我发现 C-清晰的 代码将数据写入 blob 存储.但是,我不懂 C# 语言.我需要使用 python 上传 .csv 文件.

I am trying to upload a .csv file into Microsoft Azure storage account using python. I have found C-sharp code to write a data to blob storage. But, I don't know C# language. I need to upload .csv file using python.

是否有 python 将 CSV 文件内容上传到 Azure 存储的示例?

推荐答案

我使用 this 参考链接.我的以下代码完美适用于 uploading 和 downloading .csv 文件.

I found the solution using this reference link. My following code perfectly work for uploading and downloading .csv file.

#!/usr/bin/env python from azure.storage.blob import BlockBlobService from azure.storage.blob import ContentSettings block_blob_service = BlockBlobService(account_name='<myaccount>', account_key='mykey') block_blob_service.create_container('mycontainer') #Upload the CSV file to Azure cloud block_blob_service.create_blob_from_path( 'mycontainer', 'myblockblob.csv', 'test.csv', content_settings=ContentSettings(content_type='application/CSV') ) # Check the list of blob generator = block_blob_service.list_blobs('mycontainer') for blob in generator: print(blob.name) # Download the CSV file From Azure storage block_blob_service.get_blob_to_path('mycontainer', 'myblockblob.csv', 'out-test.csv')

更多推荐

使用 python 将 CSV 文件上传到 Microsoft Azure 存储帐户

本文发布于:2023-10-26 10:15:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529840.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:帐户   文件上传   CSV   python   Microsoft

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!