I have a function to choose an excel file through the file explorer in tkinter:
import pandas as pd
from tkinter import *
from tkinter import filedialog
def fileopen():
filepath = filedialog.askopenfilename(filetypes=(("xlsx", "*.xlsx"), ("all files", "*.*"))) #windows file explorer
label = Label(window, text=filepath) #label to return file's directory path
label.pack()
label.place(x=200, y=80)
df = pd.read_excel(filepath)
This process is extremely slow. I click on the excel file and have to wait for 10-15 seconds for the path to show on my label. But when I removed the pd.read_excel() part:
def fileopen():
filepath = filedialog.askopenfilename(filetypes=(("xlsx", "*.xlsx"), ("all files", "*.*")))
label = Label(window, text=filepath)
label.pack()
label.place(x=200, y=80)
it would return the path of my excel file in an instant, so the slowness lies in the pandas function. But I can't remove it or my program won't work at all. How can I get around this?