Python Forum
Open only the Windows Explorer in Pandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Open only the Windows Explorer in Pandas
#1
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.
Reply
#2
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.
Reply
#3
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]
Reply
#4
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
Reply
#5
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.
Reply
#6
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020