Professional Documents
Culture Documents
Ip Project School Copy v-V1.4
Ip Project School Copy v-V1.4
2 | Page
S.No Contents Pg.no
1 Acknowledgement
2 Aim
3 Technical Details
4 Source Code
5 Output
6 Advantages
7 Disadvantages
8 Bibliography
3 | Page
ACKNOWLEDGEMENT
the project.
4 | Page
Documentation
Aim
This project aims to provide a simple interface to view,
modify and visualize data from a CSV file. All of this is made
Capabilities
The program houses a variety of functions to perform.
It can:
5 | Page
Brief explanation of all functions
6 | Page
Technical Details
Software Used
About Python
Libraries Used
Pandas
Matplotlib
Tkinter
Tabulate
Isense
pyvb
Colorama
OS
7 | Page
Description:
Pandas
Matplotlib
Tkinter
Tabulate
Isense
8 | Page
Colorama
OS
pyvb
9 | Page
Source Code
#<>Import-----------------------------------------------------------
-
import tkinter as tk
import pandas as pd
import os
#</>Import----------------------------------------------------------
-
#<>BgSettings-------------------------------------------------------
-
#</>BgSettings------------------------------------------------------
-
#<>Declarations-----------------------------------------------------
--
setgui = True
debugM = True
hasedited = False
"DeleteColumn", "exec_",
"DeleteRow",
10 | P a g e
init(autoreset=False)
def update():
ev = open("eval_.py","r")
code = ev.read()
exec(code)
def Main():
if setgui:
box.destroy()
Loadfile()
ui()
def auth():
unameTr = uname.get()
pwdr = pname.get()
Main()
else:
ms.execute()
def getfuncs():
file_r = open("funct.json","r")
functions_dict = json.load(file_r)
functions = functions_dict["functions"]
return functions
def printc(Msg,colr="RED"):
11 | P a g e
exec(f'print(Fore.{colr} + Back.LIGHTWHITE_EX + Msg)')
print(Fore.BLUE,Back.LIGHTWHITE_EX)
def autoeval(str_):
result = False
for x in functions_:
if(x == str_):
result = True
break
elif(x!=str_):
result=False
if(result==True):
exec(f"{str_}" + "()")
elif(result == False):
dym_ = isense.evaluate(str_)
if str_!="":
def eval_(choice):
try:
y = eval(choice)
return y
except:
return str(choice)
def printdf(df_,hdr,fmt="psql"):
if fmt == "psql":
print(tabulate(df_,headers=hdr,tablefmt="psql"))
else:
print(tabulate(df_,headers=hdr,tablefmt=fmt))
12 | P a g e
def eRRC(v1=None,v2=None):
def eRRN(msg,dym=""):
#setcol("4F")
if dym == "":
printc(f'''
===================================================================
Error:\t{msg}
===================================================================
''')
if dym !="":
printc(f'''
===================================================================
===================================================================
''')
def stOUT(out_):
printc(colr="GREEN",Msg=f'''
+----------------------------------------+
{out_}
+----------------------------------------+
''')
def Inf(msg):
printc(colr='GREEN',Msg = f'''
13 | P a g e
==========================================
(i) Info:\t{msg}
==========================================
''')
def printdbg(msg):
if debugM:
print(msg)
def dataframe():
printdf(df,"keys")
def sgst():
fn2 =
["Plot","Edit","report","save","dataframe","close","Menu","Help"]
print("\nchoose one:")
ss = pd.DataFrame(fn2)
#print(ss)
printdf(ss,["Index", "Functions"],fmt="fancy_outline")
#</>SystemFunctions-------------------------------------------------
-
#<>Initialize-------------------------------------------------------
-
isense.funcs = functions_
#</>Initialize------------------------------------------------------
--
def Menu():
print('''
14 | P a g e
''')
def Help():
print('''
''')
#</>HelpFunctions---------------------------------------------------
--
def report():
printdf(df,"keys")
ch = input("\nSelect operation:\t")
autoeval(ch)
15 | P a g e
def Showrow():
x = digestcols(ch)
if x:
Inf("Success!")
print("\n",df[ch])
else:
eRRC(v1=ch)
colsT(hlp=True)
def Showcols():
nlist = []
for i in df.columns:
nlist.append(i)
df__ = pd.DataFrame(nlist)
printdf(df__,["Index","Columns"])
def getcols():
cols__ = []
for i in df.columns:
cols__.append(i)
return cols__
def Iterate():
print("\nRowIndex:\t", row)
print("Values: ")
print(rowseries, "\n")
def Gets():
global dfGets
sf = False
sf1 = False
try:
16 | P a g e
sf1 = True
except:
if sf1:
clist = []
for i in range(ch):
clist.append(ch1)
printdbg(clist)
rlist = []
try:
dfGets = df.loc[srowidx:erowidx,clist]
sf= True
except:
if sf:
printdf(dfGets,clist)
def Max():
sf = False
clist=[]
try:
for i in df.columns:
clist.append(i)
maxL = list(df[ch])
m = maxL.index(max(maxL))
for ff in clist:
if ff!=ch:
17 | P a g e
print("\n",ff + ":\t",df.iat[m,clist.index(ff)])
sf = True
except:
eRRC(v1=ch)
colsT(hlp=True)
if sf:
def Min():
sf = False
clist=[]
try:
for i in df.columns:
clist.append(i)
minL = list(df[ch])
n= minL.index(min(minL))
for ff in clist:
if ff!=ch:
print("\n",ff + ":\t",df.iat[n,clist.index(ff)])
sf = True
except:
eRRC(v1=ch)
colsT(hlp=True)
if sf:
svalf = False
mvalf = False
18 | P a g e
ivalf = False
above:\t").lower()
if(option=="single value"):
try:
res = df[colname].get(rowidx)
svalf = True
except:
if svalf:
stOUT(f"Value:\t{res}")
elif(option=="multiple cols"):
colist = []
colist_ = ["Index"]
try:
ivalf = True
except:
if ivalf:
for i in range(nc):
{i+1}:\t"))
colist.append(cnam)
colist_.append(cnam)
try:
res1 = df.get(colist)
19 | P a g e
for i in colist:
tt = df[i]
mvalf = True
except:
records!")
colsT(hlp=True)
if mvalf:
printdf(res1,colist_)
else:
eRRN("Invalid option!")
def Query():
sf = False
{col1}=={col2}")
ll=[ch,ch2]
try:
sf = True
except:
eRRC(v1=ch,v2=ch2)
colsT(hlp=True)
if sf:
20 | P a g e
printdf(rs,ll)
#</>Report Functions------------------------------------------------
--
def ui():
while True:
sgst()
print("\n")
autoeval(ch)
def Edit():
def colsT(hlp=False):
lis = []
if hlp:
for i in df.columns:
lis.append(i)
print("\n",tabulate(pd.DataFrame(lis),headers=["Index","Columns"],ta
blefmt="psql"))
def digestcols(cname):
clistd = []
for i in df.columns:
clistd.append(i)
if(cname in clistd):
21 | P a g e
return True
elif(cname==""):
return True
else:
return False
def Modify():
sf = False
sf1 = False
try:
val__ = df.at[rval,cval]
stOUT(f"Value isolated:\t{val__}")
sf1 = True
except:
if sf1:
try:
sf=True
except:
if sf:
printdf(df,"keys")
def Loadfile():
global df
22 | P a g e
global cols_lookup
global primary_index
sf = False
global filenameC
try:
if(filenameC.endswith("csv")):
df = pd.read_csv(filenameC)
elif(filenameC.endswith("xlsx") or filenameC.endswith("xls")):
try:
df = pd.read_excel(filenameC,engine="openpyxl")
except ImportError:
time.sleep(2)
quit()
except FileNotFoundError:
time.sleep(2)
quit()
if(df.empty==True):
eRRN("Empty DataFrame!")
Loadfile()
if(df.shape[-1]>10):
chex = eval_(input("\nyes/no:\t"))
if chex == "no":
close()
23 | P a g e
sf = True
except:
Loadfile()
if sf:
printdf(df,"keys")
colsT()
try:
primary_index = cols_lookup.index(eval_(input("\nEnter
primary column:\t")))
except:
Loadfile()
if df.empty:
eRRN("Empty DataFrame")
Loadfile()
def close():
ch = input("\nyes/no:\t")
save()
quit()
else:
24 | P a g e
eRRN("Invalid option!")
def AddRow():
sf = False
row,col = df.shape;print(col)
colvals = []
columns_ = getcols()
for i in range(col):
colvals.append(cl)
try:
df.loc[ch]=colvals
sf = True
except:
if sf:
printdf(df,"keys")
def AddColumn():
sf = False
global rowvals
try:
except:
ui()
row,col = df.shape
25 | P a g e
colname = eval_(input("\nEnter column name:\t"))
rowvals = []
for i in range(row):
if ch == "":
ch = "Null"
rowvals.append(ch)
try:
df.insert(colnumber,colname,rowvals)
sf = True
except:
if sf:
printdf(df,"keys")
def exec_():
exec(input("\n>>> "))
def save():
sf = False
if cnf =="":
df.to_csv(filenameC,index=False)
df.to_html(ext+".html",index=False)
26 | P a g e
Inf("File saved as Html successfully")
df.to_excel(ext1 + "xlsx",engine="openpyxl",index=False)
df.to_csv(ext2 + ".csv",index=False)
else:
eRRN("Invalid option!")
def Plot():
autoeval(chz)
def DeleteColumn():
try:
df.drop(ch, axis=1,inplace=True)
printdf(df,"keys")
except:
eRRC(v1=ch)
colsT(hlp=True)
def DeleteRow():
try:
df.drop(ch,inplace=True)
27 | P a g e
print("\nRow deleted successfully")
printdf(df,"keys")
except:
eRRN("Invalid rowindex/name!")
def Setindex():
try:
df.set_index(ch,inplace=True)
printdf(df,"keys")
except:
eRRC(v1=ch)
colsT(hlp=True)
#</>MainFunctions---------------------------------------------------
--
#<>PlotFunctions----------------------------------------------------
--
def barexp():
useindex = useindexvar.get()
stack = stacked_.get()
xval = entry1.get()
yval=entry2.get()
xlab = entry4.get()
ylab = entry5.get()
colr = entry3.get()
arglist = [xval,yval,colr]
cmd = "df.plot.bar("
idx=-1
if(xlab!=""):
if(ylab!=""):
28 | P a g e
cmd+="xlabel=" + '"' + xlab + '",'
elif(ylab == ""):
elif(xlab == ""):
idx+=1
cmd+=","
if(arglist[idx+1]):
cmd+=","
elif(arg==yval != ""):
cmd+=","
if(arglist[idx+1]):
cmd+=","
elif(arg==colr != ""):
cmd+=","
try:
if(arglist[idx+1]):
cmd+=","
except:
29 | P a g e
cmd+=")"
cmd+=")"
printdbg(cmd)
try:
exec(cmd)
plt.title("BarGraph")
plt.show()
except:
eRRC(v1=xval,v2=yval)
colsT(hlp=True)
def Bargraph():
global entry1
global entry2
global entry3
global entry4
global entry5
global useindexvar
global stacked_
global topb
topb = tk.Tk()
topb.geometry("400x270")
useindexvar = tk.IntVar()
stacked_ = tk.IntVar()
30 | P a g e
labelT.place(relx=0.5,rely=0.11,anchor=tk.CENTER)
entry1 = tk.Entry(master=topb)
entry2 = tk.Entry(master=topb)
entry3 = tk.Entry(master=topb)
entry4 = tk.Entry(master=topb)
31 | P a g e
entry5 = tk.Entry(master=topb)
rbut.place(relx=0.5,rely=0.8,anchor=tk.CENTER)
topb.mainloop()
def linexp():
xval = entryLp1.get()
yval = entryLp2.get()
global topl
df.plot.line()
elif(xval!="" or yval!=""):
if xval:
df.plot.line(x=xval)
elif yval:
df.plot.line(y=yval)
df.plot.line(x=xval,y=yval)
plt.xlabel(xval)
plt.ylabel(yval)
plt.title(f"LinePlot")
plt.show()
else:
eRRC(v1=xval,v2=yval)
colsT(hlp=True)
def Lineplot():
32 | P a g e
global entryLp1
global entryLp2
topl = tk.Tk()
topl.geometry("300x170")
entryLp1 = tk.Entry(master=topl)
entryLp2 = tk.Entry(master=topl)
rbut.place(relx=0.5,rely=0.8,anchor=tk.CENTER)
topl.mainloop()
def histexp():
bins_r = entryHp1.get()
alpha_r = entryHp2.get()
if alpha_r:
alpha_ = float(alpha_r)
33 | P a g e
else:
alpha_ = alpha_r
if bins_r:
bins_ = int(bins_r)
else:
bins_ = bins_r
df.plot.hist(bins=bins_)
df.plot.hist(alpha=alpha_)
df.plot.hist(bins=bins_,alpha=alpha_)
elif(bins_=="",alpha_==""):
df.plot.hist()
plt.title("Histogram")
plt.show()
def Histogram():
global entryHp1
global entryHp2
toph = tk.Tk()
toph.geometry("300x170")
toph.title("Plot Histogram")
34 | P a g e
entryHp1 = tk.Entry(master=toph)
entryHp2 = tk.Entry(master=toph)
pbut.place(relx=0.5,rely=0.8,anchor=tk.CENTER)
toph.mainloop()
#</>PlotFunctions---------------------------------------------------
--
#Gui----------------------------------------------------------------
--
if setgui:
box = tk.Tk()
screen_w = box.winfo_screenwidth()
screen_h = box.winfo_screenheight()
window_wd = 300
window_he = 250
x = (screen_w-window_wd)//2 -7
y = (screen_h-window_he)//2 -25
box.geometry(f"{window_wd}x{window_he}+{x}+{y}")
35 | P a g e
label = tk.Label(master=box, text="Enter credentials",
font=("Roboto",14,"underline","bold"))
label.place(relx=0.5, rely=0.17,anchor=tk.CENTER)
uname = tk.Entry(master=box,width=25)
uname.place(relx=0.6,rely=0.5,anchor=tk.CENTER)
uname_lab = tk.Label(master=box,text="Username:",
font=("Roboto",11))
uname_lab.place(x=20, y=113)
pname_lab = tk.Label(master=box,text="Password:",
font=("Roboto",11))
pname_lab.place(x=20, y=163)
pname = tk.Entry(master=box,width=25)
pname.place(x=180,y=175,anchor=tk.CENTER)
submit_b = tk.Button(master=box,text="Login",command=auth)
submit_b.place(relx=0.5, rely=0.85,anchor=tk.CENTER)
box.mainloop()
#</>Gui-------------------------------------------------------------
-
#<>==============================End================================
=#
36 | P a g e
Advantages
Disadvantages
37 | P a g e
Output
Edit
38 | P a g e
AddRow
Modify
39 | P a g e
DeleteRow
DeleteColumn
40 | P a g e
Report
Showrow
41 | P a g e
ShowCols
Iterate
42 | P a g e
Query
43 | P a g e
Gets
Max
44 | P a g e
Min
Get
45 | P a g e
Save
46 | P a g e
Help
Plot
47 | P a g e
48 | P a g e
49 | P a g e
50 | P a g e
Bibliography
Pandas:
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.max.html
Shell color:
https://www.oreilly.com/library/view/windows-2000-
quick/0596000170/ch06s08.html
Stack overflow:
https://stackoverflow.com
Preeti Arora:
IP reader class 12 2023 edition.
Submitted by
Raghavasimhan V
Naren SK
Sanjay M
XII-B
51 | P a g e