我如何直接从Azure blob存储中读取文本文件而不将其下载到本地文件中(使用python)? [英] How can I read a text file from Azure blob storage directly without downloading it to a local file(using python)?
本文介绍了我如何直接从Azure blob存储中读取文本文件而不将其下载到本地文件中(使用python)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不下载Azure的情况下读取文本Blob?我可以下载该文件,然后读取它,但是,我希望不下载就可以读取它.
How can i reads a text blob in Azure without downloading it? I am able to download the file and then read it but, i prefer it to be read without downloading.
print("\nList blobs in the container")
generator = block_blob_service.list_blobs(container_name)
for blob1 in generator:
print("\t Blob name: " + blob.name)
'blob1'对象中是否有任何操作可以让我直接读取文本文件(例如blob1.read或blob1.text或类似的东西)?
Is there any operation in 'blob1' object, which would allow me to read the text file directly.(like blob1.read or blob1.text or something like this)?
推荐答案
You can use get_blob_to_text
method.
block_blob_service = BlockBlobService(account_name='myaccount', account_key='mykey')
blob = block_blob_service.get_blob_to_text('mycontainer', 'myblockblob')
print blob.content
这篇关于我如何直接从Azure blob存储中读取文本文件而不将其下载到本地文件中(使用python)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文