I would like to convert columns from my csv file into arrays in python however I want the first value in each column (the first row) to be the array names.
I have tried this:
import csv
data = csv.reader(open('products.csv', 'r'), delimiter=",", quotechar='|')
column1, column2 = [], []
for row in data:
column1.extend(row[0])
column2.extend(row[1])
print(column1)
print(column2)
However, this gives it character by character and does not make the array name the first value.
Here is my csv file.
name,description,price
Apples,A bag of 3 apples,1.75
White Bread,A loaf of white bread,1.90
Wholemeal Bread,A loag of wholemeal bread,1.45
It needs to be expandable (Not hardcoded/I will add to this file later)
Expected results is 3 arrays.
name = []
description = []
price = []
and the values line up e.g. index 0 in all arrays will be the first column etc etc.