I have a File Geodatabase Table(no geometry). I am trying to update the last column, called S_Name from concatenated values from other fields. I am going to write out my logic so it is clear what I want to accomplish
if the PRE_TYPE field is not Null and the SUF_TYPE field is null then update S_Name to the values of PRE_TYPE+NAME+SUF_MOD
if PRE_TYPE is Null and SUF_TYPE is Not Null then update S_Name to NAME+SUF_TYPE
Here is my code below. I am pretty sure the logic is sound. The script runs with no errors but does not print bah, and does not update the table.
import arcpy
arcpy.env.workspace = "C:path\\Tran_road_NJ.gdb"
layer = "C:path\\Tran_road_NJ.gdb\\Tran_road_geocode_NJ_1"
with arcpy.da.UpdateCursor(layer, ['PRE_TYPE','NAME','SUF_TYPE','SUF_MOD','S_Name']) as rd:
for x in rd:
if x[0] != None and x[1] != None and x[2] == None:
bah = x[0]+' '+x[1] +' '+x[3]
x[4] = str(bah)
print bah
rd.updateRow(x)
elif x[0] == None and x[1] != None and x[2] != None:
bah = x[1]+' '+x[2]
x[4] = str(bah)
print bah
rd.updateRow(x)