0% found this document useful (0 votes)
4 views2 pages

CSV Operations for Employee Records

Uploaded by

rushda.7369
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

CSV Operations for Employee Records

Uploaded by

rushda.7369
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROGRAM 13

OPERATIONS ON CSV FILE

OBJECTIVE:

Write two user defined functions to perform the following:

i. To create a csv file to store employee details

[Empno, Name,Department, Salary].

ii. To display the record of employee who works in ‘IT’ department and salary is more than 50000.

CODING:

import csv

def CREATE():

f = open(“[Link]”, “a”)

csv_writer = [Link](f)

csv_writer.writerow([“Empno”, “Name”, “Department”, “Salary”])

ans = “y”

while ans == “y”:

Empno = int(input(“Enter the employee number”))

name = input(“Enter the name”)

dept = input(“Enter the department name”)

Salary = int(input(“Enter the employee number”))

emprec = [Empno, Name, dept, Salary]

csv_writer.writerow(emprec)

ans = input(“Enter y to continue or n to exit”)

[Link]()

def Read():

f1 = open(“[Link]”, “r”, newline = “ ”)

csv_read = [Link](f1)

next(csv_read)
for line in csv_read:

if line[2]== ’IT’ and line[3] == ‘50000’:

print(line)

[Link]()

You might also like