I am trying to read a csv from Azure blob into Python as a stream and write it back to Azure blob directly. Read operation works perfectly fine butwriting output stream just writes an empty file into the blob. The following code works until print(df) but not after that.
Below is the code:
Code:
from io import BytesIO, StringIO
with BytesIO() as input_blob:
with BytesIO() as output_blob:
block_blob_service = BlockBlobService(account_name='aaaccc', account_key='*/*/*--')
block_blob_service.get_blob_to_stream('test', 'Source.csv', input_blob)
input_blob.seek(0)
df=pd.read_csv(input_blob)
print(df)
copyfileobj(input_blob, output_blob)
block_blob_service.create_blob_from_stream('test', 'OutFilePy.csv', output_blob)
copyfileobj
function do? can you edit your question and paste the definition of that? – Saher Ahwalinput_blob
's cursor is at EOF afterpd.read_csv
. Ainput_blob.seek(0)
afterread_csv
maybe helpful. – Sraw