JGuizard
4/16/2017 - 9:13 AM

Working with csv file

Working with csv file


import csv

#Read
with open('levels_ita.csv', 'rb') as f:
	reader = csv.reader(f,delimiter=';')
	for row in reader:
		print row


f.close()	

#Write
ifile  = open('test.csv', "rb")
reader = csv.reader(ifile)
ofile  = open('ttest.csv', "wb")
writer = csv.writer(ofile, delimiter='', quotechar='"', quoting=csv.QUOTE_ALL)
 
for row in reader:
    writer.writerow(row)
 
ifile.close()
ofile.close()