File loader excel pandas

Hei guys, i want to upload an excel file and use it temporarily with panda for some data analysis and then that s it. i want to dispose it. The app will be for multiple users and i dont want to save every file in data files. When i use the file loader i get this type of object <anvil._serialise.StreamingMedia object at 0x7f34079940a0> .

The q: Can i use this with panda? With csv_to_df ? For now i save the file in the data files but i want to use it without save it just when the file is on the fileloader…i hope you can understand me.

Thanks!

From memory if you have a look in the docs for TempFile this should do the trick. This creates a file on disk you can use to load your StreamingMedia object into Pandas.

1 Like

I recently had to do this so it’s fresh in my mind:
You’ll need to use get_bytes() on the Anvil streaming media object.

def read_upload(excel_file):
    file_name = excel_file.get_bytes()
    data = pandas.read_excel(file_name)
  
1 Like

Thanks mate! Superb!

1 Like