def handle(self, *path_args, **options): with open(path_args[0], 'rb') as csvfile: csvreader = csv.reader(csvfile) print "starting" next(csvreader) # to skip the headings c = 0 for counter, row in enumerate(csvreader): #import pdb; pdb.set_trace() id_ = int(row[0]) #if id_ <= 218303: continue target = int(row[-1]) dataset = TrainingDataset.objects.create(attr_ID=id_, attr_TARGET=target) for x in range(1, 1934 + 1): if x in (218, 240): #print "Skipping", x, 'of ', counter continue x_temp = x if 218 < x < 240: x_temp -= 1 if x > 240: x_temp -= 2 setattr(dataset, 'attr_VAR_' + make_equal_length(x_temp), row[x_temp]) dataset.save() if counter % 100 == 0: print counter c = counter print "Inserted", c, "rows"
print print "Select above options. [0 to go to previous dataset if you made a mistake][-1 if you want someone else to check]" print "Collecting data, please wait..." for i, obj in enumerate(TrainingDataset.objects.all()): if i > 500: break sample_datapoints.append(obj) att = lower while (att <=higher): if att in ABSENT_ATTRIBUTES: att+=1 continue print "[%d]" % att check = [getattr(x, 'attr_VAR_' + make_equal_length(att)) for x in sample_datapoints] if check is not None: print " | ".join([x if x is not None else "None" for x in check]) else: print "None found, skipping" print_info() # ask for decision done = False while not done: choice = raw_input() try: choice = int(choice) except: print "Int please" continue if choice in [x[0] for x in OPTIONS]: if(choice == -1):