write a Program to create Csv file and store empno, name,salary and
search any empno and display name,salary and if not found appropriate message.
Answers
Answered by
4
Answer:
Pls Mark Me brainliest plss
Answered by
2
Answer:using csv file with reader and writer
Explanation:
import csv
fh=open('pt2-csv.csv','w',newline='')
obj=csv.writer(fh,delimiter=',')
n=int(input("Enter the no.of employees:"))
for i in range(n):
e_no=int(input("Enter the employee number:"))
e_name=input("Enter the employee name:")
e_salary=int(input("Enter the salary:"))
obj.writerow([e_no,e_name,e_salary])
fh.close()
fh=open('pt2-csv.csv','r')
obj=csv.reader(fh,delimiter=',')
e=int(input("enter the employee number to be searched:"))
for i in obj:
if int(i[0])==e:
print("Record found")
print("Name:",i[1])
print("Salary",i[2])
break
else:
print("Record not found")
break
fh.close()
Similar questions
English,
1 month ago
Computer Science,
2 months ago
English,
2 months ago
Social Sciences,
9 months ago
Math,
9 months ago