没有调用循环,但缩进是正确的

我具有已构建的此功能,似乎我在这里遗漏了一些非常小的东西。由于某些原因,此循环不会调用。缩进看起来不错,我的输出没有任何错误,但是数据没有更新,您可以通过我未在终端中显示的调试打印语句来查看该数据。

下面是我要说的功能:

def updatefield(layer,prev_data):
print("DEUBG:: UPDATE FIELD")
fname,ftype,fdict = field_attr(prev_data)[0],field_attr(prev_data)[1],field_attr(prev_data)[2]

arcpy.AddField_management(
    in_table=layer,field_name=fname,field_type=ftype,field_is_nullable="NULLABLE"
    )

# Use UpdateCursor to expedite the copy of the data to the new field.
with arcpy.da.UpdateCursor(layer,[prev_data,fname,"OID@"]) as uc:
    print("DEUBG:: UPDATE CURSOR: {}".format(layer))
    for record in uc:
        print("\tDEBUG:: record: {}".format(record)) # THIS NEVER GETS CALLED 
        if record[0] in fdict.keys():
            record[1] = fdict[record[0]]
        else:
            if layer == fms_conduit:
                record[1] = None
            # Can't recall if you can have empty keys...These also pretty much only apply to fiber.
            elif prev_data == "CATEGORY" and record[0] == "":
                record[1] = "OTH"
            elif prev_data == "CABLECAPACITY" and (record[0] in ('',' ',None)):
                record[1] = 0
            elif prev_data == "CABLECAPACITY":
                record[1] = int(record[0])
            else:
                record[1] = ""
        print("\nDEBUG:: OID: {}\tPrevField: {}\t NewFieldName: {}\tNewFieldValue: {}".format(
            record[2],prev_data,record[1])
        )
        uc.updateRow(record)

这是输出:

没有调用循环,但缩进是正确的

最后几个调试打印语句来自另一个函数,但是我应该打印该记录。再说一次,可能有些愚蠢,但我似乎无法理解。

谢谢您的时间。

Joey209092 回答:没有调用循环,但缩进是正确的

结果证明,传递给我的数据在某些时候被截断了。更新游标为空,因此未进行任何翻译。

本文链接:https://www.f2er.com/3033970.html

大家都在问