Azure Blob - Read using Python

前端 未结 5 818
被撕碎了的回忆
被撕碎了的回忆 2020-12-14 03:18

Can someone tell me if it is possible to read a csv file directly from Azure blob storage as a stream and process it using Python? I know it can be done using C#.Net (shown

5条回答
  •  猫巷女王i
    2020-12-14 04:04

    I recommend using smart_open.

    from smart_open import open
    
    # stream from Azure Blob Storage
    with open('azure://my_container/my_file.txt') as fin:
        for line in fin:
            print(line)
    
    # stream content *into* Azure Blob Storage (write mode):
    with open('azure://my_container/my_file.txt', 'wb') as fout:
        fout.write(b'hello world')
    

提交回复
热议问题