title: Python - create an arbitrary number of lists to store all values in a column
body: <p>I have csv files in which the number of columns are not constant. For each column, I am trying to store all values in that column into a separate list so that I can count the number of recurring values. I have written some code to do this but, it does not seem to <code>append</code> into a list well enough.</p>
  
  <p>Sample input is <code>love hurt hit</code>. 
  My input is a csv file with a varible number of rows and a variable number of columns. It keeps changing for a different csv file. Say one file has 3 columns and the next file has 20 columns. Yes and no are the values which are present under all those columns. The occurrence of those values is random. What I want to do is extract all the values in each individual column, and append them to a list. So, once I exit the for loop, I would ideally like to see all values in a given column; not the last value nor each value printed one below the other. </p>
  
  <p>When I append all the values, it should be <code>['love', 'yes' 'no', 'yes' ......]</code> where <code>yes</code> and <code>no</code> are values under the column of <code>love</code>.
  Instead, I have each value printed on a new line such as:</p>
  
  <p><code>['love']</code></p>
  
  <p><code>['yes']</code></p>
  
  <p>....</p>
  
  <p>This is what I have so far. Please help!</p>
  
  <pre><code>a,b,c = [],[],[]
  headings = []
  allCols = []
  
  def getColCount(currLine):
      return len(currLine)    
  
  # Open the file and read it
  with open(filename1, 'r') as f1:
  
   csvlines = csv.reader(f1, delimiter=',')
  
   for lineNum, line in enumerate(csvlines):
        colCount = getColCount(line)               
        allCols = [[] for x in range(0, colCount)]         
  
        a.append(line[0])            # this prints like I want it to - in series
  
        for i in range(0, colCount):
  
             allCols[i].append(line[i])   # this doesn't
  
        print ','.join(allCols[2])
  </code></pre>