How to read a csv via pd.read_csv from an uploaded csv file?

Hi guys!

I’m trying to read a csv via pd.read_csv, uploaded via your uploader -

It doesn’t seem to work - Am I using the correct file?

Thanks! :raised_hands:
Charly

Hi @Charly_Wargnier, thanks for the question!

You can use q.site.download to bring the file from the Wave server to your machine, and then read into pandas. In this example, file_upload is the name of my ui.file_upload

q.client.working_file_path = await q.site.download(
   url=q.args.file_upload[0], 
   path='./my_local_data_location'
)

df = pd.read_csv(q.client.working_file_path)

Here’s an example app which allows for uploading a dataset and then displaying a table, to show you how it all works together:

1 Like

Thanks @mtanco! I’ll try. :slight_smile:

Btw, is this expected to get an issue on the former script (I’m using Windows 10)?

Here’s the error I get:

Error

Traceback (most recent call last):
  File "c:\users\charly\desktop\wave-apps\venv\lib\site-packages\h2o_wave\server.py", line 265, in _process
    await self._handle(q)
  File ".\upload_Best.py", line 16, in serve
    await handle_uploaded_data(q)
  File ".\upload_Best.py", line 82, in handle_uploaded_data
    make_ui_plot_card(q)
NameError: name 'make_ui_plot_card' is not defined

Thanks,
Charly

oops, good catch! I forgot to comment out a different function I was testing :slight_smile: it’s been updated

1 Like

Thanks Michelle for the prompt response! :pray:

Apologies, I should have checked and comment it out myself :slight_smile:

Out of interest:

  • What would be the max file size or row limit per CSV, if any?
  • Would it be possible to filter a table from the UI, then export the filtered state?

Thanks,
Charly