![]() ![]() Reorder_fields(in_fc, out_fc, new_field_order) ![]() # use merge with single input just to use new field_mappingsĪrcpy.Merge_management(table, out_table, new_mapping) Raise Exception("Field: ".format(field_name, table)) If field_name not in existing_field_names: # required fields (OBJECTID, etc) will not be in existing mappingsįield_map = existing_mapping.fieldMappings Mapping_index = existing_mapping.findFieldMapIndex(field_name) :add_missing: add missing fields to end if True (leave out if False)Įxisting_fields = arcpy.ListFields(table)Įxisting_field_names = :field_order: order of fields (objectid, shape not necessary) :out_table: output table (fc, table, layer, etc) :table: input table (fc, table, layer, etc) Reorders fields in input featureclass/table Here is a python script that uses the Merge Tool to reorder fields (Copied from here) import arcpyĭef reorder_fields(table, out_table, field_order, add_missing=True): It is recommended to use Merge tool once and then use Copy As Python Snippet and then manually change the fields' order and then paste the python code in python windows. Although re-ordering via the dialog is not a perfect approach. The reordering can be done through python script and even with the Tool dialog (By removing a field and re-adding it in the dialog). It works with tables and feature classes. With the Merge Tool, you can easily reorder fields permanently. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |