Programming Examples
Python program to write data on csv file
Write a python program which accept data from user and write in csv file.
import csv
fp=open("data1.csv","w",newline="")
obj=csv.writer(fp)
stu=['roll','name','city']
obj.writerow(stu)
for a in range(1,3):
r=int(input("Enter the Roll "))
n=input("Enter any name")
c=input("Enter any City")
stu=[r,n,c]
obj.writerow(stu)
fp.close()
Output