Python Forum

Full Version: Open only the Windows Explorer in Pandas
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! How can I open only the workbook to choose the .csv files I want to open with pandas? I know the method of the entire path to the file and not only to the workbook.
Question does not quite make sense. What notebook software are you using? Jupyter? Colab? VSCode? You want to open the notebook and then load the contents of a csv file into a Pandas dataframe? Your question leaves me guessing.
I'm sorry. I think I didn't explain it properly. I want to write Python code that opens a window for me to choose the .csv or .xlsx files on directory just like the one in the attached image window. And yes, loading the contents of a .csv or .xlsx file into a Pandas dataframe. I'm using the Anaconda.
[Image: images.jpg]
You want a file selector. First you need to decide which GUI you plan to use and look up how to use a file selector with that. I use wx, and the file selector widget is at https://wxpython.org/Phoenix/docs/html/w...rCtrl.html

Tkinter is probably the most popular GUI, and the file selector is described at https://docs.python.org/3/library/dialog.html
Great!!! The application I am building is for loading different .csv or .xlsx files so I would only need access to the folder where they will be. I just know how to write the code in Pandas to load only one file.
import pandas as pd
df = pd.read_csv('blah.csv')
df1 = pd.read_excel('blah.xls')
So, use the dialog to select the file, then use the pd.read_xxx routines to read the file selected.