Python program to create a CSV file named “students.csv” to store Roll , name and percentage of students
#writing records in csv file
import csv
f=open('student.csv','w',newline='')
stdwriter=csv.writer(f,delimiter=',')
stdwriter.writerow(['Rollno','Name','Marks']) # write header row
stdrec= [
['101', 'Nikhil', '99'],
['102', 'Sanchit', '98'],
['103', 'Aditya', '98'],
['104', 'Sagar', '87'],
['105', 'Prateek', '88'],
]
stdwriter.writerows(stdrec)
f.close()
Output:-
Rollno,Name,Marks
101,Nikhil,69
102,Sanchit,98
103,Aditya,98
104,Sagar,87
105,Prateek,88
106,Abhay,99
No comments:
Post a Comment