Download our e-book of Introduction To Python
Shashank Shanu
4 years ago
# Import Library
from azure.storage.blob import BlockBlobService
import pandas as pd
import tables
with BytesIO() as input_blob:
with BytesIO() as output_blob:
block_blob_service = BlockBlobService(account_name='STORAGEACCOUNTNAME', account_key='STORAGEACCOUNTKEY')
# Download as a stream
block_blob_service.get_blob_to_stream('STORAGEACCOUNTNAME', 'History.csv', input_blob)
# Do whatever you want to do - here I am just copying the input stream to the output stream
df=pd.read_csv('blobstorageurl/swxbotcontainer/History.csv')
df=df.append(pd.DataFrame([["How to update password","john@gmail.com","John"]],columns=['User Query','Email','User Name']))
df.to_csv('History.csv',index=false)
#df_b = df.to_string()
#block_blob_service.create_blob_from_csv('STORAGEACCOUNTNAME', 'History.csv', df)
block_blob_service.create_blob_from_path('STORAGEACCOUNTNAME','History.csv','History.csv',content_settings=ContentSettings(content_type='application/CSV'))