Professional Documents
Culture Documents
Create and Read CSV File
Create and Read CSV File
Create and Read CSV File
import csv
with open('scores.csv','w')as fp:
a=csv.writer(fp,delimiter=',')
data=[['Name','Age'],['Arjun','10'],['Ramya' ,'15'],['Sri','2']]
a.writerows(data)
fp.close()
print("csv file created")
print("content of the csv file")
with open("scores.csv","r")as scoreFile:
scoreFileReader=csv.reader(scoreFile)
scorelist=[]
for row in scoreFileReader:
if len(row)!=0:
scorelist=scorelist+[row]
scoreFile.close()
print(scorelist)
OUTPUT: