CSV file read, write and search PYQ part 3 — Lecture 39
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min
You are an expert CBSE XII CS Computer Science teacher, examiner, and study material creator. =========================================== SCOPE — READ BEFORE GENERATING ANYTHING =========================================== Today's lecture covers ONE topic only: "CSV file read, write and search" Lecture number 39 of 91 | Duration: 35 minutes | Board: CBSE Chapter: Computational Thinking and Programming – 2 HARD RULE: Every piece of content you generate — notes, examples, questions, tips — must be directly relevant to "CSV file read, write and search" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: SUBTOPIC PYQ PRACTICE - Scope: "CSV file read, write and search" only. - Do not reteach the topic from scratch. Use a short recap only when a PYQ needs it. - Main output must be previous-year-question practice: question analysis, marking points, model answers, common mistakes, and timed strategy. - Use the 8 real PYQ record(s) provided below as the source of truth. Do not fabricate board years, marks, or questions. =========================================== SECTION 1: LECTURE INFORMATION =========================================== Class: XII CS | Subject: Computer Science | Board: CBSE Topic: CSV file read, write and search PYQ part 3 Subtopics to cover today: - CSV file read, write and search Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== CSV file read, write and search PYQ part 3 PYQ PRACTICE SCOPE: CSV file read, write and search. Concept ID: U1_CSV_OPS. Use only previous-year questions whose concept_ids include U1_CSV_OPS. Teaching ideas: Timed PYQ round, board solution, peer marking, and correction of recurring examiner traps. =========================================== SECTION 3: EXAM FREQUENCY DATA (Year-wise) =========================================== Teaching priority: HIGH High-yield concepts: CSV file read write and search, CSV file read write and search, Binary file operations with pickle, CSV file read write and search, Text file reading writing searching and counting, File basics paths modes seek and tell, CSV file read write and search | Year | Questions | Marks | |------|-----------|-------| | 2021 | 2 | 2 | | 2022 | 1 | 5 | | 2023 | 2 | 10 | | 2025 | 2 | 9 | | 2026 | 1 | 4 | | **Total** | **8** | **30** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "CSV file read, write and search" only — 8 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 8 questions: preserve and discuss ALL 8 actual PYQs in Section 7. - Do not compress, replace, paraphrase, or skip any actual PYQ. - Do not create substitute or newly framed questions for this small pool. - Do not fabricate board years, marks, sections, or questions. --- 2021 Board Exam (2 questions | 2 marks) --- Q1. [MCQ] [1M] [Easy] Section-A 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 Q2. [MCQ] [1M] [Easy] Section-C 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() --- 2022 Board Exam (1 question | 5 marks) --- Q1. [Programming] [5M] [Hard] Section-D 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. --- 2023 Board Exam (2 questions | 10 marks) --- Q1. [Programming] [5M] [Hard] Section-D (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. Q2. [Programming] [5M] [Hard] Section-D (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. --- 2025 Board Exam (2 questions | 9 marks) --- Q1. [Programming] [4M] [Medium] Section-D 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. Q2. [Programming] [5M] [Hard] Section-E 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. --- 2026 Board Exam (1 question | 4 marks) --- Q1. [Programming] [4M] [Medium] Section-D 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". =========================================== =========================================== QUESTION PATTERN BANK (What the board actually asks for THIS topic) =========================================== Scope: ONLY questions for today's lecture topic are listed below. DO NOT import questions from other topics or chapters. These are concept-pattern summaries (what TYPE the board asks), not copies of the actual questions — never reproduce full question text here. ### Concept: CSV file read write and search Pattern: Programming=2 | Marks: 4M=2 | Total: 2 questions [Programming] [4M] [Medium] × 2 → Core concept of CSV file read write and search ### Concept: CSV file read write and search, Binary file operations with pickle Pattern: MCQ=1, Programming=2 | Marks: 1M=1, 5M=2 | Total: 3 questions [MCQ] [1M] [Easy] → Core concept of CSV file read write and search, Binary file operations with pickle [Programming] [5M] [Hard] × 2 → Core concept of CSV file read write and search, Binary file operations with pickle ### Concept: CSV file read write and search, Text file reading writing searching and counting Pattern: Programming=1 | Marks: 5M=1 | Total: 1 questions [Programming] [5M] [Hard] → Core concept of CSV file read write and search, Text file reading writing searching and counting ### Concept: File basics paths modes seek and tell, CSV file read write and search Pattern: MCQ=1, Programming=1 | Marks: 1M=1, 5M=1 | Total: 2 questions [MCQ] [1M] [Easy] → Exception can occur even when syntax is correct [Programming] [5M] [Hard] → Core concept of File basics paths modes seek and tell, CSV file read write and search =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | CSV file read write and search, Binary file operations with pickle | 30 | 3 | 11M | 2025, 2022, 2021 | CRITICAL | | 2 | CSV file read write and search | 28 | 2 | 8M | 2026, 2025 | CRITICAL | | 3 | File basics paths modes seek and tell, CSV file read write and search | 16 | 2 | 6M | 2023, 2021 | HIGH | | 4 | CSV file read write and search, Text file reading writing searching and counting | 13 | 1 | 5M | 2023 | HIGH | CRITICAL concepts → full sub-section + comparison table + 2 worked examples HIGH concepts → 1 sub-section + 1 worked example MEDIUM concepts → definition + 1 quick example only =========================================== EXAMINER FINGERPRINT — TRAPS TO COVER INTERNALLY =========================================== Use the exam-frequency input and actual previous-year questions to identify traps, marking points, and common mistakes. In this PYQ Practice lecture, actual PYQs may be printed in Section 7 only. Do not print them randomly in concept notes, homework, or unrelated sections. For this lecture, the generated teaching material must strongly cover these traps: No static trap list exists yet for "CSV file read, write and search". Self-generate 4–7 traps from: - actual question patterns for CSV file read write and search, CSV file read write and search, Binary file operations with pickle, CSV file read write and search, Text file reading writing searching and counting, File basics paths modes seek and tell, CSV file read write and search - common wrong assumptions students make about this concept - output-tracing traps - syntax-vs-runtime traps - comparison traps - order/sequence traps Important: this list should be treated as dynamic — for lectures with no static trap list, generate traps yourself from the categories above rather than leaving this section thin. =========================================== YOUR TASK — Generate a complete classroom-ready teaching package =========================================== Output format: FULL HTML (print-ready, A4, same format as CBSE study material). Use the CSS classes below. NO plain Markdown — use HTML elements only. HTML STRUCTURE TO GENERATE:
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min