import csv

from django.core.management.base import BaseCommand, CommandError

from wafer.tickets.views import import_ticket


class Command(BaseCommand):
    args = '<csv file>'
    help = "Import a guest list CSV from Quicket"

    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError('1 CSV File required')

        with open(args[0], 'r') as f:
            reader = csv.reader(f)

            header = next(reader)
            if len(header) != 11:
                raise CommandError('CSV format has changed. Update wafer')

            for ticket in reader:
                self.import_ticket(*ticket)

    def import_ticket(self, ticket_number, ticket_barcode, purchase_date,
                      ticket_type, ticket_holder, email, cellphone, checked_in,
                      checked_in_date, checked_in_by, complimentary):
        import_ticket(ticket_barcode, ticket_type, email)

@@ -341,24 +341,346 @@
 required')%0A%0A
+        columns = ('Ticket Number', 'Ticket Barcode', 'Purchase Date',%0A                   'Ticket Type', 'Ticket Holder', 'Email', 'Cellphone',%0A                   'Checked in', 'Checked in date', 'Checked in by',%0A                   'Complimentary')%0A        keys = %5Bcolumn.lower().replace(' ', '_') for column in columns%5D%0A%0A
         with
@@ -762,16 +762,22 @@
 eader = 
+tuple(
 next(rea
@@ -780,16 +780,17 @@
 (reader)
+)
 %0A       
@@ -801,25 +801,25 @@
  if 
-len(
 header
-)
  != 
-11
+columns
 :%0A  
@@ -908,22 +908,19 @@
     for 
-ticket
+row
  in read
@@ -943,44 +943,53 @@
     
-self.import_ticket(*ticket
+ticket = dict(zip(keys, row)
 )%0A
-%0A
     
-def
+           
  imp
@@ -1003,264 +1003,130 @@
 ket(
-self, ticket_number, ticket_barcode, purchase_date,%0A                      ticket_type, ticket_holder, email, cellphone, checked_in,%0A                      checked_in_date, checked_in_by, complimentary):%0A        import_ticket(ticket_barcode, ticket_type, 
+ticket%5B'ticket_barcode'%5D,%0A                              ticket%5B'ticket_type'%5D,%0A                              ticket%5B'
 email
+'%5D
 )%0A

Check CSV header, not column count (and refactor)