My code successfully loads the CSV data into the tk.grid entry. However, I am encountering an error when attempting to load all the tk.grid data into a pandas dataframe. I would appreciate it if you could review my code and provide me with some ideas on how to accomplish this task.
import tkinter
import csv
import pandas as pd
root = tkinter.Tk()
# open file
with open("c:/erp/book1.csv", newline="") as file:
reader = csv.reader(file)
df1=pd.read_csv('c:/erp/book1.csv')
df_list=list(df1.columns.values)
df_rset=df1.to_numpy().tolist()
# r and c tell us where to grid the labels
for r, col in enumerate(reader):
for c, row in enumerate(col):
mlabel = tkinter.Entry( root, width=10 )
mlabel.grid(row=r, column=c,sticky="ew")
mlabel.insert(0, row)
dataFrame = pd.DataFrame()
new_row= df_list
a,b = root.grid_size()
for c in a:
for r in b:
dataFrame.append(mlabel.grid[c][r]) # it give error
root.mainloop()
for c in a:
for r in b:
dataFrame.append(mlabel.grid[c][r]) # it give error