from tkinter import filedialog as fd
filename = fd.askopenfilename(title = "Select file",filetypes = (("CSV Files","*.csv"),("All","*.*")))
Opens the folder to choose the file, but when I try:
from tkinter import filedialog as fd
filename = fd.askopenfilename(title = "Select file",filetypes = ("CSV Files","*.csv"))
Error:
Traceback (most recent call last): File "D:\python_projects\csv_codes\csv_reading.py", line 4, in filename = fd.askopenfilename(title = "Select file",filetypes = ("CSV Files" ,"*.csv")) File "C:\Python\lib\tkinter\filedialog.py", line 375, in askopenfilename return Open(**options).show() File "C:\Python\lib\tkinter\commondialog.py", line 43, in show s = w.tk.call(self.command, w._options(self.options)) _tkinter.TclError: bad file type ".csv", should be "typeName {extension ?extens ions ...?} ?{macType ?macTypes ...?}?"
What exactly I want?:
I want only .CSV
files to be selected. (compulsory)