def getValueMap(row, names, sourceValue, field):

    # run value map function for a row
    valueMaps = field.getElementsByTagName("ValueMap")
    newValue = None
    found = False
    otherwise = None
    for valueMap in valueMaps:
        try:
            otherwise = valueMap.getElementsByTagName("Otherwise")[0]
            otherwise = dla.getTextValue(otherwise)
        except:
            otherwise = None
        sourceValues = []
        sourceValues = valueMap.getElementsByTagName("sValue")
        targetValues = []
        targetValues = valueMap.getElementsByTagName("tValue")
        i = 0
        for val in sourceValues:
            sValue = dla.getTextValue(val)
            try:
                sourceTest = float(sValue)
            except ValueError:
                sourceTest = str(sValue)
                if sourceTest == '':
                    sourceTest = None
            #if mapExpr and mapExpr != "":
            #    sourceValue = calcValue(row,names,mapExpr)
            if sourceValue == sourceTest or sourceValue == sValue:  # this will check numeric and non-numeric equivalency for current values in value maps
                found = True
                try:
                    newValue = dla.getTextValue(targetValues[i])
                except:
                    dla._errCount += 1
                    success = False
                    err = "Unable to map values for " + sourceValue + ", value = " + str(
                        newValue)
                    dla.showTraceback()
                    dla.addError(err)
                    print(err)
            i = i + 1
    if not found:
        if str(otherwise) != "None":
            newValue = otherwise
        else:
            dla._errCount += 1
            success = False
            err = "Unable to find map value (otherwise) for " + str(
                targetName) + ", value = " + str(sourceValue)
            dla.addError(err)
    return newValue
def getValueMap(row,names,sourceValue,field):

    # run value map function for a row
    valueMaps = field.getElementsByTagName("ValueMap")
    newValue = None
    found = False
    otherwise = None
    for valueMap in valueMaps:
        try:
            otherwise = valueMap.getElementsByTagName("Otherwise")[0]
            otherwise = dla.getTextValue(otherwise)
        except:
            otherwise = None
        sourceValues = []
        sourceValues = valueMap.getElementsByTagName("sValue")
        targetValues = []
        targetValues = valueMap.getElementsByTagName("tValue")
        i = 0
        for val in sourceValues:
            sValue = dla.getTextValue(val)
            try:
                sourceTest = float(sValue)
            except ValueError:
                sourceTest = str(sValue)
                if sourceTest == '':
                    sourceTest = None
            #if mapExpr and mapExpr != "":
            #    sourceValue = calcValue(row,names,mapExpr)
            if sourceValue == sourceTest or sourceValue == sValue: # this will check numeric and non-numeric equivalency for current values in value maps
                found = True
                try:
                    newValue = dla.getTextValue(targetValues[i])
                except:
                    dla._errCount += 1
                    success = False
                    err = "Unable to map values for " + sourceValue + ", value = " + str(newValue)
                    dla.showTraceback()
                    dla.addError(err)
                    print(err)
            i = i + 1
    if not found:
        if str(otherwise) != "None":
            newValue = otherwise
        else:
            dla._errCount += 1
            success = False
            err = "Unable to find map value (otherwise) for " + str(targetName) + ", value = " + str(sourceValue)
            dla.addError(err)
    return newValue
def getConcatenate(row, names, field):
    concatFields = field.getElementsByTagName("cField")
    sep = field.getElementsByTagName("Separator")[0]
    sep = dla.getTextValue(sep)
    sep = sep.replace("(space)", " ")
    concat = []
    for cfield in concatFields:
        node = cfield.getElementsByTagName("Name")
        nm = dla.getTextValue(node[0])
        nameidx = names.index(nm)
        if row[nameidx] != None:
            concat.append(str(row[nameidx]))
    concatStr = concatRepair(concat, sep)
    if concatStr == "":
        concatStr = None
    return concatStr
def getConcatenate(row,names,field):
    concatFields = field.getElementsByTagName("cField")
    sep = field.getElementsByTagName("Separator")[0]
    sep = dla.getTextValue(sep)
    sep = sep.replace("(space)"," ")
    concat = []
    for cfield in concatFields:
        node = cfield.getElementsByTagName("Name")
        nm = dla.getTextValue(node[0])
        nameidx = names.index(nm)
        if row[nameidx] != None:
            concat.append(str(row[nameidx]))
    concatStr = concatRepair(concat,sep)
    if concatStr == "":
        concatStr = None
    return concatStr
Beispiel #5
0
def getDomainMap(row, sourceValue, field):

    # run domain map function for a row
    valueMaps = field.getElementsByTagName("DomainMap")
    newValue = sourceValue
    found = False
    otherwise = None
    for valueMap in valueMaps:
        sourceValues = []
        sourceValues = valueMap.getElementsByTagName("sValue")
        targetValues = []
        targetValues = valueMap.getElementsByTagName("tValue")
        i = 0
        for val in sourceValues:
            sValue = dla.getTextValue(val)
            try:
                sourceTest = float(sValue)
            except ValueError:
                sourceTest = str(sValue)
                if sourceTest == '' or sourceTest == 'None':
                    sourceTest = None
            if sourceValue == sourceTest or sourceValue == sValue:  # this will check numeric and non-numeric equivalency for current values in maps
                found = True
                try:
                    newValue = dla.getTextValue(targetValues[i])
                except:
                    dla._errCount += 1
                    success = False
                    err = "Unable to map values for " + sourceValue + ", value = " + str(
                        newValue)
                    dla.showTraceback()
                    dla.addError(err)
                    print(err)
            i = i + 1

    return newValue