AnsweredAssumed Answered

Delete column before exporting to excel

Question asked by CCweedcontrol on Apr 29, 2016
Latest reply on May 4, 2016 by bixb0012

I have a script that creates a excel file but i need it to delete the "OID" field prior to exporting to excel, is this possible or does it have to be done after the export?

 

I have tried the following, it runs fine and i don't get error.

 

# Process: Make Feature Layer (2)
arcpy.MakeFeatureLayer_management("In_memory\Blah", "In_memory\Blah3")

#fields = arcpy.ListFields("In_memory\Blah3", "OID")
#if len(fields) != 1:
#    arcpy.DeleteField_management("OID")
    
fields = [f.name for f in arcpy.ListFields("In_memory\Blah3")]

for i,f in enumerate(fields):
    if f == 'OID':
        del fields[i]

# Process: Table Select
arcpy.TableToExcel_conversion("In_memory\Blah3",Listing_xls)

Outcomes