CSV Files: Class 12 PYQs 2024–2026 with solutions
All 4 CBSE board questions asked from CSV Files in 3 board papers, with the year, set and marks of each. 3 are solved free below. The Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE) has every solution, all chapters and 3 full board papers.
CSV Files: board weightage
Board weightage 2024–2026
| Year | 2024 | 2025 | 2026 |
|---|---|---|---|
| Questions | 2 | 1 | 1 |
| Marks | 5 | 4 | 4 |
Most asked topics
4 questions from 3 papers. Repeated questions are shown once with every year they were asked.
1 mark: MCQ and Assertion–Reason
A–R. (A): A CSV file is a human readable text file where each line has a number of fields, separated by comma or some other delimiter. (R): writerow() method is used to write a single row in a CSV file.
Solution
(b) Both are true, but R (a fact about writing) does not explain why a CSV file is human-readable text.
4 marks: SQL / case-based
"States.csv" (with a header row) has [State, Capital, Population, Language], e.g. ['Andhra Pradesh','Amaravati',52221000,'Telugu']. Write a program that appends all records with population more than 10000000 to 'More.csv' (do not copy the header).
Solution
import csv
with open('States.csv') as F1:
with open('More.csv', 'a', newline='') as F2:
R = csv.reader(F1)
W = csv.writer(F2)
RECS = list(R)
for rec in RECS[1:]: # skip the header row
if int(rec[2]) > 10000000:
W.writerow(rec)
For Andhra Pradesh (52221000), Goa (1458545) and Kerala (35699443), More.csv receives the Andhra Pradesh and Kerala rows. Mode 'w' was also accepted.
"P_record.csv" records: [Name, Disease, Days admitted, Amount], e.g. ["Gunjan","Jaundice",4,15000]. Write (i) read_data() to display the details of all 'Cancer' patients; (ii) count_rec() to count and return the number of records.
Solution
import csv
def read_data():
with open("P_record.csv", "r") as F:
for R in csv.reader(F):
if R[1] == "Cancer":
print(R)
def count_rec():
with open("P_record.csv", "r") as F:
Records = list(csv.reader(F))
return len(Records)
Peripheral.csv has [P_id, P_name, Price] (P_id int, P_name str, Price int). Write Add_Device() to accept a record and add it to the file, and Count_Device() to count and display devices with price less than 1000.
Get every solution for all chapters
- Every board question of every chapter, each fully solved the way the board gives marks
- 3 complete board papers, each followed by its solutions
- Weightage and most-asked topics for every chapter
- Instant PDF download, colour and black & white print copies
Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →
What you get in the pack
- CBSE Class 12 Computer Science board papers 2024 to 2026 (3 full board papers)
- All 14 chapters and 3 board papers complete
- Part A: all 14 chapters, questions sorted chapter-wise and by marks
- Year-wise weightage table and most-asked topics for every chapter
- Part B: each full board paper followed by its complete solutions
- Full programs; every output traced and verified by running the code
- Only the current syllabus in Part A
All chapters in this pack
- PYQ Ch 1 Python Revision Tour
- PYQ Ch 2 Functions
- PYQ Ch 3 Exception Handling
- PYQ Ch 4 Text Files
- PYQ Ch 5 Binary Files
- PYQ Ch 6 CSV Files
- PYQ Ch 7 Stack
- PYQ Ch 8 Computer Networks I: Evolution and Data Communication
- PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
- PYQ Ch 10 Network Protocols and Web Services
- PYQ Ch 11 Database Concepts
- PYQ Ch 12 SQL: DDL, DML and Queries
- PYQ Ch 13 SQL: Aggregates, Grouping and Joins
- PYQ Ch 14 Interface of Python with MySQL
- Board Paper 2026 Set 91 with Solutions
- Board Paper 2025 Set 91 with Solutions
- Board Paper 2024 Set 91 with Solutions
