I work with a sample of CSV file which is like this :
3256221406917,DESCRIPTION1,"U Bio, U",food
3256223662106,DESCRIPTION2,"U Bio, U",food
I want to parse it with comas :
def import_csv(csvfilepath):
data = []
product_file = open(csvfilepath, "r")
reader = csv.reader(product_file, delimiter=',')
for row in reader:
if row: # avoid blank lines
columns = [row[0], row[1], row[2], row[3], row[4]]
data.append(columns)
return data
However it returns a "list index out of range" issue when running.
I believe that the trouble might come from third and fourth column as there is opening and closing double quotes. But I don't understand why the delimiter = ','
seems not used.
Do you know why ? Thank you for your help !
EDIT :
Thank you all I was simply not sure why "," was read after '"' and if there was a way to change it, but it seems simpler to remove the ' "' before !