AnsweredAssumed Answered

Copy attributes from layer to table except OID and Geometry

Question asked by CCweedcontrol on Aug 27, 2019
Latest reply on Aug 27, 2019 by CCweedcontrol

I am trying to copy attributes from a layer to a table but the Geometry fields are giving me problems. I need help ignoring the OID and Geometry fields and i though line 11 would do it.


The feature class fields

Shape.STArea() & Shape>STLength()


Table fields

Shape_STarea_ & Shape_STLength


I have the following but get error.

line 17, in <module>
RuntimeError: Cannot find field 'Shape.STArea()'


arcpy.env.workspace = r"C:Temp\Test.gdb"
database = r"C:Temp\Test.gdb"
fc1 = "TestLayer1
fc2 = "Table1"

dsc = arcpy.Describe(fc1)
fields = dsc.fields

# List all field names except the OID field and geometry fields
fieldnames = [ for fields in fields if != dsc.OIDFieldName and fields.type != 'Geometry']
# Create cursors and insert new rows

with arcpy.da.SearchCursor(fc1,fieldnames) as sCur:
    with arcpy.da.InsertCursor(fc2,fieldnames) as iCur:
        for row in sCur:
del sCur