0% found this document useful (0 votes)
31 views11 pages

CBSE Class 12 Python CSV Notes

The document contains Python code to work with CSV files. It includes functions to write data to a CSV file by taking user input, read the CSV file and print its contents, search the CSV file by roll number, and find the row with the maximum marks. The code takes student data like roll number, name, and marks as input and stores it in a CSV file.

Uploaded by

bhayyavikas1
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)
31 views11 pages

CBSE Class 12 Python CSV Notes

The document contains Python code to work with CSV files. It includes functions to write data to a CSV file by taking user input, read the CSV file and print its contents, search the CSV file by roll number, and find the row with the maximum marks. The code takes student data like roll number, name, and marks as input and stores it in a CSV file.

Uploaded by

bhayyavikas1
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

CBSE CLASS 12 PYTHON

CSV Files

Notes By: Anand Sir | YouTube Channel: CODEITUP


Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
Notes By: Anand Sir | YouTube Channel: CODEITUP
def write():
import csv
with open("[Link]","w",newline='') as fobj:
f=[Link](fobj)
[Link](['Roll','Name','Marks'])
while True:
roll=int(input("Enter Roll Number:"))
name=input("Enter Name:")
marks=int(input("Enter Marks:"))
data=[roll,name,marks]
[Link](data)
choice=int(input("1->Enter More\n2-
>Exit\nEnter Your Choice:"))
if choice==2:
break
print("File Created Successfully...")

Notes By: Anand Sir | YouTube Channel: CODEITUP


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

def search():
import csv
with open("[Link]","r") as fobj:
f=[Link](fobj)
next(f)
rno=int(input("Enter Roll Number to Search:"))
gurpreet=0
for i in f:
if int(i[0])==rno:
gurpreet=1
print(i)
break
if gurpreet==0:
print("Roll Number Not Found...")
Notes By: Anand Sir | YouTube Channel: CODEITUP
def max():
import csv
with open("[Link]","r") as fobj:
f=[Link](fobj)
next(f)
maxnum=0
for i in f:
if int(i[2])>maxnum:
maxnum=int(i[2])
z=i
print("Max Value=",z)

#__main__
#write()
#read()
#search()
#max()
countrows()

Notes By: Anand Sir | YouTube Channel: CODEITUP

You might also like