Tkinter Read file to create Pandas DataFrame

Tkinter Projects in Tkinter Pandas

Tkinter Pandas DataFrame
Use the file browser to connect to any csv ( Comma Separated value ) file on click of a button. Use the read_csv() method to create a Pandas Dataframe by using the selected csv file.

After creation of Dataframe , display the number of rows and columns in the dataframe by using DataFrame attribute shape.
import pandas as pd
import tkinter  as tk 
from tkinter import *
from tkinter import filedialog
from tkinter.filedialog import askopenfile
my_w = tk.Tk()
my_w.geometry("400x300")  # Size of the window 

my_font1=('times', 12, 'bold')
l1 = tk.Label(my_w,text='Read File & create DataFrame',
b1 = tk.Button(my_w, text='Browse File', 
   width=20,command = lambda:upload_file())

def upload_file():
    f_types = [('CSV files',"*.csv"),('All',"*.*")]
    file = filedialog.askopenfilename(filetypes=f_types)
    l1.config(text=file) # display the path 
    df=pd.read_csv(file) # create DataFrame
    str1="Rows:" + str(df.shape[0])+ "\nColumns:"+str(df.shape[1])
    t1.insert(tk.END, str1) # add to Text widget
my_w.mainloop()  # Keep the window open

Projects in Tkinter
Create Pandas DataFrame by reading Google Analytics csv file from Tkinter GUI
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer