def handle_noargs(self, **options):
        data_reader = csv.reader(open(SOURCE_FILE))

        def clean_int(value):
            if value <> '':
                value = float(value.replace(',', '').replace(' ', ''))
                value = int(value * 1000)
            else:
                value = None
            return value

        for i, row in enumerate(data_reader):
            if i == 0:
                year_row = row
            else:
                for j, col in enumerate(row):
                    if j == 0:
                        state = col.strip()
                    elif j > 0:
                        if len(state):
                            year = year_row[j]
                            try:
                                record = MedicaidParticipation.objects.get(
                                    state=state, year=year)
                            except MultipleObjectsReturned:
                                print 'error: multiple records exist for ' + str(
                                    year_row[j]) + ' ' + state
                                continue
                            except:
                                record = MedicaidParticipation()
                                record.state = state
                                record.year = year
                            value = col
                            record.value = clean_int(value)
                            record.save()
 def handle_noargs(self, **options):
     data_reader = csv.reader(open(SOURCE_FILE))
     
     def clean_int(value):
         if value <> '':
             value = float(value.replace(',','').replace(' ', ''))
             value = int(value * 1000)
         else:
             value = None
         return value
     
     for i, row in enumerate(data_reader):
         if i == 0:
             year_row = row;            
         else:
             for j,col in enumerate(row):
                 if j == 0:
                     state = col.strip()
                 elif j > 0:
                     if len(state):
                         year = year_row[j]
                         try:
                             record = MedicaidParticipation.objects.get(state=state, year=year)
                         except MultipleObjectsReturned:
                             print 'error: multiple records exist for ' + str(year_row[j]) + ' ' + state
                             continue
                         except:
                             record = MedicaidParticipation()
                             record.state = state
                             record.year = year
                         value = col
                         record.value = clean_int(value)
                         record.save()