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

Day 07 Python File Handling - CSV Files

The document provides Python code for handling CSV files related to student records, including functions to write, read, search, and find maximum and minimum marks. It allows users to input student data, save it to a CSV file, and retrieve information based on roll numbers. The code is structured for educational purposes, specifically for Class 12 Computer Science curriculum.

Uploaded by

itskunj11
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 views10 pages

Day 07 Python File Handling - CSV Files

The document provides Python code for handling CSV files related to student records, including functions to write, read, search, and find maximum and minimum marks. It allows users to input student data, save it to a CSV file, and retrieve information based on roll numbers. The code is structured for educational purposes, specifically for Class 12 Computer Science curriculum.

Uploaded by

itskunj11
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

CODEITUP

CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File
import csv
def write():
with open("[Link]","w",newline='')as fobj:
f=[Link](fobj)
[Link](['Roll','Name','Marks'])
while True:
roll=int(input("Enter Roll umber:"))
name=input("Enter Name:")
marks=int(input("Enter Marks:"))
data=[roll,[Link](),marks]
[Link](data)
choice=int(input("1->Enter More\n2-
>Exit\nEnter your Chocie:"))
if choice==2:
break
print("File Created Successfully...")

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

def read():
with open("[Link]","r")as fobj:
f=[Link](fobj)
for i in f:
print(i)

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

def search():
with open("[Link]","r")as fobj:
f=[Link](fobj)
roll=int(input("Enter Roll Number to Find:"))
flag=0
next(f)
for i in f:
if int(i[0])==roll:
flag=1
print(i)
break
if flag==0:
print("Roll Number Not Found")

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses
CODEITUP
CS Class 12 | Chapter 06 | CSV File

def max(): def min():


with open("[Link]","r")as fobj: with open("[Link]","r")as fobj:
f=[Link](fobj) f=[Link](fobj)
maxm=-1 minm=101
next(f) next(f)
for i in f: for i in f:
if int(i[2])>maxm: if int(i[2])<minm:
maxm=int(i[2]) minm=int(i[2])
z=i z=i
print("Student with Max Marks=",z) print("Student with Min
Marks=",z)

Get the CBSE CS PYTHON Class 12 Enroll in Class 12 Explore


[Link] book by Anand Sir CS/CUET CS Live Batches C/C++/Java Courses

You might also like