I'm trying to append multiple columns of a csv to multiple lists. Column 1 will go in list 1, column 2 will go in list 2 etc...
However I want to be able to not hard code in the number of columns so it could work with multiple csv files. So I've used a column count to assign how many lists there should be.
I'm coming unstuck when trying to append values to these lists though. I've initiated a count that should be able to assign the right column to the right list however it seems like the loop just exits after the first loop and wont append the other columns to the list.
import csv
#open csv
f = open('attendees1.csv')
csv_f = csv.reader(f)
#count columns
first_row = next(csv_f)
num_cols = len(first_row)
#create multiple lists (within lists) based on column count
d = [[] for x in xrange(num_cols)]
#initiate count
count = 0
#im trying to state that whilst the count is less than the amount of columns, rows should be appended to lists, which list and which column will be defined by the [count] value.
while count < (num_cols):
for row in csv_f:
d[count].append(row[count])
count += 1
print count
print d