Computer Science, asked by ashmidev007, 2 months ago

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 sanjayds524
4

Answer:

Pls Mark Me brainliest plss

Answered by yudheekshanawork
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