ar d
ar d

Reputation: 69

How to read data from azure blob storage with BlobServiceClient without downloading rather by using BytesIO stream

I don't want to get any downloads just get stream of data which I can read using Pandas later

>! the parameters of BlobServiceClient are correctly provided
BSC= BlobServiceClient() 
self.stream = BytesIO()
BSC.get_blob_client(
            self.container, self.filename
        ).download_blob(offset=0).readinto(self.stream)

Actually I want replcaement for this below code which is using older version of azure-storage-blob

self.servivce = BlockBLobService()
self.stream = BytesIO()
self.service.get_blob_to_stream(self.container, self.filename, self.stream)
self.stream.seek(0)
wrapper = TextIOWrapper(self.stream, encoding="utf-8")
return wrapper

Upvotes: 1

Views: 832

Answers (1)

Botje
Botje

Reputation: 31193

From the documentation:

io.StringIO(
  BSC.get_blob_client(self.container, self.filename).content_as_text())

Upvotes: 1

Related Questions