def importPredios(filename):
    ins = open(filename, "r")
    line = ins.readline()
    header = map(lambda f: f.strip('\n').strip('"').lower(), line.split('|'))
    print header
    for line in ins:
        fields = map(lambda f: f.strip('\n').strip('"'),
                     line.replace(',', '.').split('|'))
        node = RegistroPredioCatastroTipoII()
        record = {}
        map(lambda k, v: record.update({k: v}), header, fields)
        map(lambda k, v: setattr(node, k, v), header, fields)
        node.fecha_documento = parseDateFromTwoDigitYear(record['fecha_documento'])
        try:
            node.save()
        except :
            print record
Exemple #2
0
def importPredios(filename):
    ins = open(filename, "r")
    line = ins.readline()
    header = map(lambda f: f.strip('\n').strip('"').lower(), line.split('|'))
    print header
    for line in ins:
        fields = map(lambda f: f.strip('\n').strip('"'),
                     line.replace(',', '.').split('|'))
        node = RegistroPredioCatastroTipoII()
        record = {}
        map(lambda k, v: record.update({k: v}), header, fields)
        map(lambda k, v: setattr(node, k, v), header, fields)
        node.fecha_documento = parseDateFromTwoDigitYear(
            record['fecha_documento'])
        try:
            node.save()
        except:
            print record
def importPrediosWithCreateMethod(filename):
    ins = open(filename, "r")
    line = ins.readline()
    header = map(lambda f: f.strip('\n').strip('"').lower(), line.split('|'))
    print header
    batchList = []
    for line in ins:
        fields = map(lambda f: f.strip('\n').strip('"'),
                     line.replace(',', '.').split('|'))
        record = {}
        map(lambda k, v: record.update({k: v}), header, fields)
        record['fecha_documento'] = parseDateFromTwoDigitYear(record['fecha_documento'])
        batchList.append(record)
        if len(batchList) > 1000:
            try:
                RegistroPredioCatastroTipoII.create(*batchList)
            except Exception as e :
                print "Error " + str(e) + " in"
                print batchList
            batchList = []
    RegistroPredioCatastroTipoII.create(*batchList)
    print "No more todo"
Exemple #4
0
def importPrediosWithCreateMethod(filename):
    ins = open(filename, "r")
    line = ins.readline()
    header = map(lambda f: f.strip('\n').strip('"').lower(), line.split('|'))
    print header
    batchList = []
    for line in ins:
        fields = map(lambda f: f.strip('\n').strip('"'),
                     line.replace(',', '.').split('|'))
        record = {}
        map(lambda k, v: record.update({k: v}), header, fields)
        record['fecha_documento'] = parseDateFromTwoDigitYear(
            record['fecha_documento'])
        batchList.append(record)
        if len(batchList) > 1000:
            try:
                RegistroPredioCatastroTipoII.create(*batchList)
            except Exception as e:
                print "Error " + str(e) + " in"
                print batchList
            batchList = []
    RegistroPredioCatastroTipoII.create(*batchList)
    print "No more todo"