title: I am trying to make an array for each column of a CSV file,
body: <p>I have an excel document that I have exported as CSV. It looks like this:</p>
  
  <pre><code>"First Name","Last Name","First Name","Last Name","Address","City","State"
  "Bob","Robertson","Roberta","Robertson","123 South Street","Salt Lake City","UT"
  "Leo","Smart","Carter","Smart","827 Cherry Street","Macon","GA"
  "Mats","Lindgren","Lucas","Lindgren","237 strawberry xing","houston","tx"
  </code></pre>
  
  <p>I have a class called "Category" that has a name variable. My code makes a category for each of the first line strings, but now I need to add each item to the column that it is supposed to go in.</p>
  
  <pre><code>import xlutils
  from difflib import SequenceMatcher
  from address import AddressParser, Address
  from nameparser import HumanName
  import xlrd
  import csv
  
  class Category:
      name = ""
      contents = []
      index = 0
  
  columns = []
  alltext = ""
  
  with open('test.csv', 'rb') as csvfile:
      document = csv.reader(csvfile, delimiter=',', quotechar='\"')
      for row in document:
          alltext = alltext + ', '.join(row) + "\n"
  
      splitText = alltext.split('\n')
  
  
      categoryNames = splitText[0].split(', ')
      ixt = 0
      for name in categoryNames:
          thisCategory = Category()
          thisCategory.name = name
          thisCategory.index = ixt
          columns.append(thisCategory)
          ixt = ixt + 1
  
  
      for line in splitText:
          if(line != splitText[0] and len(line) != 0):
              individualItems = line.split(', ')
              for index, item in enumerate(individualItems):
                  if(columns[index].index == index):
                      print(item + " (" + str(index) + ") is being sent to " + columns[index].name)
                      columns[index].contents.append(item)
      for col in columns:
          print("-----" + col.name + " (" + str(col.index) + ")-----")
          for stuff in col.contents:
              print(stuff)
  </code></pre>
  
  <p>As the code runs, it gives an output for each item that says:</p>
  
  <pre><code>Bob (0) is being sent to First Name
  Robertson(1) is being sent to Last Name
  </code></pre>
  
  <p>Which is what it should be doing. Every item says that it is being sent to the correct category. At the end, however, instead of having each item be in the category that it claims, every category has every item, and instead of this:</p>
  
  <pre><code>-----First Name-----
  Bob
  Roberta
  Leo
  Carter
  Mats
  Lucas
  </code></pre>
  
  <p>And so on and so forth, for each of the categories. I get this:</p>
  
  <pre><code>-----First Name-----
  Bob
  Robertson
  Roberta
  Robertson
  123 South Street
  Salt Lake City
  UT
  Leo
  Smart
  Carter
  Smart
  827 Cherry Street
  Macon
  GA
  Mats
  Lindgren
  Lucas
  Lindgren
  237 strawberry xing
  houston
  tx
  </code></pre>
  
  <p>I don't know what is going wrong. There is nothing in between those two lines of code that could possibly be messing it up.</p>