Monday, 27 July 2026
Lecture 36 of 73 · Unit 1
Unit 1 ⏳ Pending
Unlocks at 05:00 PM, 27 Jul 2026

CSV file read, write and search Theory

What We'll Learn

A quick overview of today's lecture

CSV file read, write and search Theory Concept ID: U1_CSV_OPS. Primary Sub-subtopic: CSV file read, write and search. Question-bank grouping: File Handling. Use this lecture for theory, examples, misconceptions, and short concept checks mapped to this concept ID.
Key things we'll cover
CSV file read, write and search
PYQ references used by both prompts 26 included 2 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6489 · 2021 · 1 mark(s)
Which of the following character acts as default delimiter in a csv file? a) (colon) : b) (hyphen) - c) (comma) , d) (vertical line) |
File Handling → CSV file read write and search
Included ID 6490 · 2021 · 1 mark(s)
Syntax for opening Student.csv file in write mode is myfile = open("Student.csv","w",newline=''). What is the importance of newline=''? a) A newline gets added to the file b) Empty string gets appended to the first line. c) Empty string gets appended to all lines. d) EOL translation is suppressed
File Handling → File basics paths modes seek and tell, CSV file read write and search
Included ID 6491 · 2021 · 1 mark(s)
What is the correct expansion of CSV files? a) Comma Separable Values b) Comma Separated Values c) Comma Split Values d) Comma Separation Values
File Handling → CSV file read write and search
Included ID 6492 · 2021 · 1 mark(s)
Which of the following is not a function/method of csv module in Python? a) read() b) reader() c) writer() d) writerow()
File Handling → CSV file read write and search
Included ID 6521 · 2021 · 1 mark(s)
Rohit, a student of class 12, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code to create a CSV File 'Student.csv' with content: 1,AKSHAY,XII,A 2,ABHISHEK,XII,A 3,ARVIND,XII,A 4,RAVI,XII,A 5,ASHISH,XII,A Incomplete Code: import _____ #Statement-1 fh = open(_____, _____, newline='') #Statement-2 stuwriter = csv._____ #Statement-3 data = [] header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] data.append(header) for i in range(5): roll_no = int(input("Enter Roll Number : ")) name = input("Enter Name : ") Class = input("Enter Class : ") section = input("Enter Section : ") rec = [_____] #Statement-4 data.append(_____) #Statement-5 stuwriter._____(data) #Statement-6 fh.close() Identify the suitable code for blank space in the line marked as Statement-1. a) csv file b) CSV c) csv d) cvs
File Handling → CSV file read write and search
Included ID 6522 · 2021 · 1 mark(s)
Identify the missing code for blank space in line marked as Statement-2. (Refer to the CSV file creation code in the case study: fh = open(_____, _____, newline='')) a) "Student.csv","wb" b) "Student.csv","w" c) "Student.csv","r" d) "Student.cvs","r"
File Handling → CSV file read write and search
Included ID 6523 · 2021 · 1 mark(s)
Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3. (Refer to the CSV file creation code in the case study: stuwriter = csv._____) a) reader(fh) b) reader(MyFile) c) writer(fh) d) writer(MyFile)
File Handling → CSV file read write and search
Included ID 6524 · 2021 · 1 mark(s)
Identify the suitable code for blank space in line marked as Statement-4. (Refer to the CSV file creation code in the case study: rec = [_____]) a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION' b) ROLL_NO, NAME, CLASS, SECTION c) 'roll_no','name','Class','section' d) roll_no,name,Class,section
File Handling → CSV file read write and search
Included ID 6525 · 2021 · 1 mark(s)
Identify the suitable code for blank space in the line marked as Statement-5. (Refer to the CSV file creation code in the case study: data.append(_____) ) a) data b) record c) rec d) insert
File Handling → CSV file read write and search
Included ID 6526 · 2021 · 1 mark(s)
Choose the function name that should be used in the blank space of line marked as Statement-6 to create the desired CSV File. (Refer to the CSV file creation code in the case study: stuwriter._____(data)) a) dump() b) load() c) writerows() d) writerow()
File Handling → CSV file read write and search, Binary file operations with pickle
Included ID 6544 · 2022 · 1 mark(s)
Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a text file. Reason (R): The information is organized with one record on each line and each field is separated by comma. a) Both A and R are true and R is the correct explanation for A b) Both A and R are true and R is not the correct explanation for A c) A is True but R is False d) A is false but R is True
File Handling → CSV file read write and search
Included ID 6565 · 2022 · 5 mark(s)
What is the advantage of using a csv file for permanent storage? Write a Program in Python that defines and calls the following user defined functions: (i) ADD() – To accept and add data of an employee to a CSV file 'record.csv'. Each record consists of a list with field elements as empid, name and mobile to store employee id, employee name and employee salary respectively. (ii) COUNTR() – To count the number of records present in the CSV file named 'record.csv'. (ii) search() – To display the records of the furniture whose price is more than 10000.
File Handling → CSV file read write and search
Included ID 6566 · 2022 · 5 mark(s)
Give any one point of difference between a binary file and a csv file. Write a Program in Python that defines and calls the following user defined functions: (i) add() – To accept and add data of an employee to a CSV file 'furdata.csv'. Each record consists of a list with field elements as fid, fname and fprice to store furniture id, furniture name and furniture price respectively. (ii) search() – To display the records of the furniture whose price is more than 10000.
File Handling → CSV file read write and search, Binary file operations with pickle
Included ID 6605 · 2023 · 4 mark(s)
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.
File Handling → CSV file read write and search
Included ID 6125 · 2023 · 5 mark(s)
(a) Write one difference between CSV and text files. Write a program in Python that defines and calls the following user defined functions : (i) COURIER_ADD(): It takes the values from the user and adds the details to a csv file 'courier.csv'. Each record consists of a list with field elements as cid, s_name, Source, destination to store Courier ID, Sender name, Source and destination address respectively. (ii) COURIER_SEARCH() : Takes the destination as the input and displays all the courier records going to that destination. (ii) Search_Book(): Takes publisher name as input and counts and displays number of books published by them.
File Handling → CSV file read write and search, Text file reading writing searching and counting
Included ID 6126 · 2023 · 5 mark(s)
(b) Why it is important to close a file before exiting ? Write a program in Python that defines and calls the following user defined functions : (i) Add_Book(): Takes the details of the books and adds them to a csv file 'Book.csv'. Each record consists of a list with field elements as book_ID, B_name and pub to store book ID, book name and publisher respectively. (ii) Search_Book(): Takes publisher name as input and counts and displays number of books published by them.
File Handling → CSV file read write and search
Excluded ID 6321 · 2023 · 5 mark(s)
(a) Write a point of difference between append (a) and write (w) modes in a text file. Write a program in Python that defines and calls the following user defined functions : (i) Add_Teacher() : It accepts the values from the user and inserts record of a teacher to a csv file "Teacher.csv". Each record consists of a list with field elements as T_id, Tname and desig to store teacher ID, teacher name and designation respectively. (ii) Search_Teacher() : To display the records of all the PGT (designation) teachers. (ii) Count_Device() : To count and display number of peripheral devices, whose price is less than or equal to 1000.
File Handling → CSV file read write and search
Awaiting categorisation review
Included ID 6322 · 2023 · 5 mark(s)
(b) Write one point of difference between seek() and tell() functions in file handling. Write a program in Python that defines and calls the following user defined functions : (i) 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. (ii) Count_Device() : To count and display number of peripheral devices, whose price is less than or equal to 1000.
File Handling → File basics paths modes seek and tell, CSV file read write and search
Included ID 6342 · 2024 · 1 mark(s)
__________ files are stored in a computer in a sequence of bytes. (A) Text (B) Binary (C) CSV (D) Notepad
File Handling → CSV file read write and search
Included ID 6160 · 2024 · 3 mark(s)
Write the user defined function to modify the quantity of a product. The function should accept the product number, and the new quantity as arguments and update the quantity of that product in a CSV file "Product.csv".
File Handling → CSV file read write and search
Included ID 6363 · 2024 · 4 mark(s)
Mr. Mahesh is a Python Programmer working in a school. He has to maintain the records of the sports students. He has created a csv file named sports.csv, to store the details. The structure of sports.csv is : [sport_id, competition, prize_won] where sport_id, is Sport id (integer) competition is competition name (string) prize_won is ("Gold", "Silver", "Bronze") Mr. Mahesh wants to write the following user-defined functions : Add_detail() : to accept the detail of a student and add to a csv file, "sports.csv". Count_Medal() : to display the name of competitions in which students have won "Gold" medal. Help him in writing the code of both the functions.
File Handling → CSV file read write and search
Included ID 6654 · 2024 · 4 mark(s)
A csv file "Happiness.csv" contains the data of a survey. Each record of the file contains the following data: - Name of a country - Population of the country - Sample Size (Number of persons who participated in the survey in that country) - Happy (Number of persons who accepted that they were Happy) For example, a sample record of the file may be: ['Signiland', 5673000, 5000, 3426] Write the following Python functions to perform the specified operations on this file: (I) Read all the data from the file in the form of a list and display all those records for which the population is more than 5000000. (II) Count the number of records in the file.
File Handling → CSV file read write and search
Excluded ID 6166 · 2024 · 5 mark(s)
Write a user defined function in Python named write_data() to write the data in a CSV file Stock.csv with field names Product_Name, Product_ID, Quantity, Price as shown below: | Product_Name | Product_ID | Quantity | Price | |--------------|------------|----------|-------| | Keyboard | P101 | 10 | 800 | | Mouse | P102 | 12 | 600 | | Monitor | P103 | 5 | 5000 | | CPU | P104 | 8 | 10000 | (ii) pop_record(): To pop the elements from the stack and display. Also display "No Record" when there are no elements in the stack.
Stack Data Structure → CSV file read write and search, Stack concept and operations using list
Awaiting categorisation review
Included ID 6216 · 2025 · 4 mark(s)
Consider the table RESULT given below. | ROLL | SUBJECT | MARKS | |------|---------|-------| | S01 | Physics | 90 | | S02 | Chemistry | 98 | | S03 | Maths | 80 | | S04 | Physics | 95 | | S05 | Chemistry | 75 | | S06 | Maths | 97 | Write a program in Python to write the above data in a CSV file named RESULT.csv and display the records of all those students who are getting marks more than 80.
File Handling → CSV file read write and search
Included ID 6413 · 2025 · 4 mark(s)
Suman is an intern at a software startup. The company has assigned her a task to create a CSV file named CLUB.CSV, to store the records of the Club members. After discussing with Club Incharge, Suman has planned to store the following content of members in the file CLUB.CSV : [Mno, Name, Mobile, Fee] Where Mno – Member Number, Name – Name of the Member, Mobile – Member's Mobile Number, Fee – Fee amount Assuming you are asked to help Suman in her assignment, write a Python code for performing the following tasks with the help of user-defined functions : NewMembers() : to accept records of members from the user and add them to the file CLUB.CSV PriorityMember() : to find and display those members from the file CLUB.CSV, who are paying Fee more than 35000.
File Handling → CSV file read write and search
Included ID 6701 · 2025 · 4 mark(s)
Raj is the manager of a medical store. To keep track of sales records, he has created a CSV file named Sales.csv, which stores the details of each sale. The columns of the CSV file are: Product_ID, Product_Name, Quantity_Sold and Price_Per_Unit. Help him to efficiently maintain the data by creating the following user-defined functions: I. Accept() – to accept a sales record from the user and add it to the file Sales.csv. II. CalculateTotalSales() – to calculate and return the total sales based on the Quantity_Sold and Price_Per_Unit.
File Handling → CSV file read write and search
Included ID 6417 · 2025 · 5 mark(s)
Keshav is the IT Head in a hospital. He needs to manage the records of all the doctors in the hospital. For this, he wants to store the following information of each doctor in a file : D_ID – An integer to store Doctor ID. D_Name – A string to store doctor's name. D_Dept – A string to store the Department of the doctor. (Surgery, Radiology, etc.) Experience – An integer to store doctor's experience (in years) For example, a doctor's information may be : [1256, 'R. Gupta', 'Cardiology', 15] As an applicant for the post of a Programmer, you have to answer the following questions in this context : (I) Write one difference of storing this data in a binary file over a CSV file. (II) Assume that the data is stored in a binary file, named DOCTORS.DAT, and each record is stored as a list. Write a function, in Python, to read and display all the records from the file DOCTORS.DAT. (III) Write a function addDoctor(), in Python, which accepts a doctor's data from the user and writes it in the file DOCTORS.DAT.
File Handling → CSV file read write and search, Binary file operations with pickle
Included ID 6261 · 2026 · 4 mark(s)
A csv file "States.csv" contains some data about all the states of India. Each record of the file contains the following data : · Name of the State · Capital of the State · Population of the State · Official Language of the State For example, a sample record in the file is : ['Andhra Pradesh', 'Amaravati', 52221000, 'Telugu'] Write a Python program which reads the data from this file and appends all those records where population is more than 10000000 into another csv file 'More.csv'. Note : "States.csv" also contains the Header row. The Header row should NOT be copied to "More.csv".
File Handling → CSV file read write and search
.txt