Guy
Guy

Reputation: 191

How to load a file to jupyter notebook using browse / file explorer?

Is there an option to browse and import a file into Jupyter lab / notebook using windows file explorer?

I've made a file that analyze csv files. I want to let the users to pick the file they want without dealing with writing the path on their own, but rather using the regular browse method as in the figure: enter image description here

Is this kind of things is possible?

Upvotes: 0

Views: 3130

Answers (2)

krassowski
krassowski

Reputation: 15379

Just click "Upload files" button in the file browser tab:

enter image description here

Upvotes: 1

Seon
Seon

Reputation: 3975

The ipyfilechooser module does exactly what you want:

from IPython.display import display
from ipyfilechooser import FileChooser

# Create and display a FileChooser widget
fc = FileChooser('/default/path')
# Set a file filter patern
fc.filter_pattern = '*.csv'
display(fc)

# Print the selected filename
print(fc.selected_filename)

Upvotes: 3

Related Questions