AnsweredAssumed Answered

Keeping Object ID field only and deleting any other field

Question asked by on Aug 29, 2019
Latest reply on Aug 29, 2019 by bixb0012

Pretty straight forward. I am building a tool that outputs an Excel file with XYZ data pertaining to a polyline route. Parameters include:

Input Points (points have been generated along a line fc every 1 meter)

Input DEM

Output Location for Excel sheet


The tool takes the input points, make a copy, SUPPOSED TO DELETE ALL FIELDS EXCEPT OBJECT ID, uses Add XY tool, then uses Extract Value to get the elevation, and finally exports the table to an Excel file. So the issue is when i am trying to delete all the fields except Object ID. All i get is a runtime error: error executing tool. I have tried many versions of my code to delete the fields. Here is one example:

SaveList                = ["OBJECTID", "OBJECT_ID", "ObjectID"]

for feild in arcpy.ListFields(Copied_Points):
     if not in SaveList:
          arcpy.DeleteField_management(Copied_Points, feild)
del field


Any thoughts on how to make this work? Thanks guys/gals.