import csv
import pandas as pd
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
while True:
print(" MAIN NENU")
print("1. Display employee data")
print("2. Add employee data")
print("3. Search employee")
print("4. Modify employee record")
print("5. Delete employee record")
print("6. Exit")
ch=int(input("Enter your choice "))
if ch==1:
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
print("The employees details are:- ")
print(df)
elif ch==2:
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
r=int(input("Enter employee's emp_id: "))
n=input("Enter employee's name: ")
d=input("enter employee's DOJ(DD-MM-YY): ")
t=input("Enter employee's DOB(DD-MM-YY): ")
p=input("Enter employee's Department: ")
s=int(input("Enter employee's Salary: "))
df.loc[len(df.index)]=[r,n,d,t,p,s]
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("Record added sucessfully")
elif ch==3:
print("1. Search by emp_id: ")
print("2. Search by ename: ")
print("3. Search by Department: ")
ans=int(input("enter your choice "))
if ans==1:
r=int(input("Enter the emp_id which record you want to search: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
src=df[df["emp_id"]==r].index
print(df.loc[src])
elif ans==2:
n=input("Enter the ename which record you want to search: ")
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
src=df[df["ename"]==n].index
print(df.loc[src])
elif ans==3:
d=input("Enter the Department which record you want to search: ")
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
src=df[df["Department"]==d].index
print(df.loc[src])
elif ch==4:
print("1. Modify emp_id")
print("2. Modify ename")
print("3. Modify DOJ")
print("4. Modify DOB")
print("5. Modify Department")
print("6. Modify Salary")
ans=int(input("Enter your choice: "))
if ans==1:
e=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==e].index
e_id=int(input("Enter the new emp_id of the employee: "))
df.at[chn,"emp_id"]=e_id
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("emp_id modified sucessfully")
if ans==2:
e=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==e].index
ename=input("Enter the new ename of the employee: ")
df.at[chn,"ename"]=ename
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("Name modified sucessfully")
if ans==3:
e=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==e].index
d=input("Enter the new DOJ of the employee(DD-MM-YY): ")
df.at[chn,"DOJ"]=d
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("DOJ modified sucessfully")
if ans==4:
e=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==e].index
db=input("Enter the new DOB of the employee(DD-MM-YY): ")
df.at[chn,"DOB"]=db
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("DOB modified sucessfully")
if ans==5:
d=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==d].index
dt=input("Enter the new department of the employee: ")
df.at[chn,"Department"]=dt
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("Department modified sucessfully")
if ans==6:
d=int(input("Enter the emp_id which record you want to modify: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
chn=df[df["emp_id"]==d].index
s=int(input("Enter the new salary of the employee: "))
df.at[chn,"Salary"]=s
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("Salary modified sucessfully")
elif ch==5:
D=int(input("Enter the employee id which record you want to delete: "))
df=pd.read_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv")
dlt=df[df["emp_id"]==D].index
df.drop(dlt,inplace=True)
df.to_csv("C:\\Users\\joga\\OneDrive\\Desktop\\Project.csv",index=False)
print("data deleted sucessfully")
elif ch==6:
print("Thanks.........................visit again")
break
Successfully add Translate Button by Google go to bottom of this website and select language the page will translate in selected language.
ReplyDeleteHow much you can earn from your website? Please reply
ReplyDeleteNot enough earn to get new equipments.
Delete