Upload CSV file into Microsoft Azure storage account using python(使用 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 存储帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 python 将 CSV 文件上传到 Microsoft Azure 存储帐户


基础教程推荐
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01