Read a csv file with python

1. Create a simple csv file with some contents.
for ex:
test1;test2;test3
test4;test5;test6

2. Execute the following python code:

import csv
 
mycsvfile = open('myfile.csv', 'r')
data = csv.reader(mycsvfile, delimiter=';', quotechar='"')
 
for row in data:
	print (' '.join(row))

WARNING!
Do NOT save your file as csv.py!
Because the above code won’t work..

Categories: Python Tags: , , ,
%d bloggers like this: