- create a BytesIO object
- convert the dataframe to an excel file or csv where the first argument is the BytesIO object
- create a BlobMedia object from the BytesIO object, calling its
getvalue()
method
An example with excel file
With csv file
content = io.BytesIO()
df.to_csv(content)
blob = anvil.BlobMedia(content_type='text/csv', content=content.getvalue())
return blob
3 Likes