Saving big data frame from pandas in client code

  1. create a BytesIO object
  2. convert the dataframe to an excel file or csv where the first argument is the BytesIO object
  3. 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