KEMBAR78
CSV File Programs | PDF | Comma Separated Values | String (Computer Science)
0% found this document useful (0 votes)
48 views1 page

CSV File Programs

The document outlines several Python programming tasks involving reading from and writing to CSV files. It includes functions for searching items, calculating salaries, filtering voter records, and managing sports results, among others. Each task specifies the structure of the CSV files and the required operations to be performed on the data.

Uploaded by

Hardik Aggarwal
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)
48 views1 page

CSV File Programs

The document outlines several Python programming tasks involving reading from and writing to CSV files. It includes functions for searching items, calculating salaries, filtering voter records, and managing sports results, among others. Each task specifies the structure of the CSV files and the required operations to be performed on the data.

Uploaded by

Hardik Aggarwal
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
You are on page 1/ 1

CSV File

1. WAP to write and read data from a CSV File consisting ITEMNO ,ITEMNAME,QTY and
PRICE. Write a functon to search for a particular item using ItemCode. Write a user
defined function search() to display those items which are in the range of 10000 and
60000.
2. WAP to write and read data from a CSV File consisting EmpNo. , EmpName and Salary
Write a functions to find the sum of salary of all Employees and count the number of
employees who are getting salary more than 7000.
3. WAP to write and read data from a CSV File consisting Voter_ID,VoterName,VoterAge
Write a function to display those records where voter age is more than 65.
4. Write a Python program to write data in a csv file “Department.csv” , consisting of : Depid
,Dept Name ,DeptLocation.
Print only the Deptname and DeptLocation.

5. Write a program in Python that defines and calls the following user defined functions :
Add_Device() : The function accepts and adds records of the peripheral devices to a csv
file ‘peripheral.csv’. Each record consists of a list with field elements as P_id, P_name and
Price to store peripheral device ID, device name, and price respectively.
Count_Device() : To count and display number of peripheral devices, whose price is less
than ₹ 1000.
6. Vedansh is a Python programmer working in a school. For the Annual Sports Event, he
has created a csv file named Result.csv, to store the results of students in different sports
events.
The structure of Result.csv is :[St_Id, St_Name, Game_Name, Result] Where
St_Id is Student ID (integer) ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost' or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the following user
defined functions:
Accept() – to accept a record from the user and add it to the file Result.csv. The column
headings should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event.
As a Python expert, help him complete the task.

7. Write a program in Python that defines and calls the following user defined functions:
i) InsertRow()- To accept and insert data of a student to a CSV file ‘class.csv’ . Each
record consists of a list with field elements as roll no , name and marks to store
roll number , student’s name and marks respectively.
ii) CountD()- To count and return the number of students who scored marks greater
than 75 stored in the CSV file named ‘class.csv’.

8. Abhishek is making a software on “Countries & their Capitals” in which various records
are to be stored/retrieved in CAPITAL.CSV data file. It consists of some records. As a
programmer, you have to help him to successfully execute the program.
(A) Write a function in Python named AddNewRec(Country,Capital) to append following
records in the file “CAPITAL.CSV”.
[“FRANCE”,”PARIS”]
[“SRILANKA”,”COLOMBO”]
(B) Write a function in Python named ShowRec( ) that will show all the contents of
CAPITAL.CSV

You might also like