Wouldn’t it be fantastic if you can share a Jupyter Notebook with your coworkers and allow them to upload a new file which is processed by your note

File upload widget in Jupyter Notebook web app

submited by
Style Pass
2022-01-27 17:00:11

Wouldn’t it be fantastic if you can share a Jupyter Notebook with your coworkers and allow them to upload a new file which is processed by your notebook? I will show you how to add file upload widget to your Jupyter Notebook and share it as a web app with Mercury framework.

I assume that you have a GitHub repository set, created virtual environment and installed Mercury. You can read how to do this in our article: Share Jupyter Notebook as web app

Our notebook will read uploaded data file and display a Pandas data frame. Please remember to add pandas package in the requirements.txt file.

In the params there is defined filename variable and file upload widget. The same variable should be defined in the cell below.

In the code I set some example.csv file. I put this file here to make the code executable. You can check the file in my repository:

The Mercury is a perfect tool to share your Python Notebook with non-coders. You can easily add interactive widgets to Jupyter Notebook. No need to rewrite your code into any web-framework.

Leave a Comment