ArcMap allows you to re-order fields in an attribute table, by dragging+dropping either within the layer's > Properties > Fields tab, or within the Table window.

However, the order of the fields doesn't seem to be honoured when exporting this table to a new table.

Is it possible to preserve the order of fields when exporting an attribute table?

  • How are you exporting the table? From the UI or geoprocessing tool?
    – Hornbydd
    Oct 20 '14 at 8:07
  • @Hornbydd I'm exporting using the > Export option from the Attribute Table Oct 20 '14 at 8:46
  • 1
    I use ET Geowizards to do this. I have a paid version but I believe this tool may be one of the free ones.
    – johns
    Oct 20 '14 at 13:12

I do not believe there is a tool or function that allows you to export a table with reordered fields. If anyone knows better please enlighten me! I've always felt it has been a bit of a limitation that the geo-processing tools do not honour the reordered fields. Especially the conversion tools .

In the past I had attempted to create a tool that did it. The following Python code can be used to re-order fields in a table by creating a new table with the fields re-ordered. In this example output (the new table) is sent to an IN_MEMORY workspace.

inputTable = "ABC" # This is a table loaded into ArcMap
outputTable = "XYZ"

# Get field mappings of Input Table
fieldMappings = arcpy.FieldMappings()

# Create an empty FieldMappings Object
newFieldMappings = arcpy.FieldMappings()

# Add fields in desired order. Note field index must be known

# Create Table
arcpy.TableToTable_conversion(inputTable, "IN_MEMORY", outputTable, None, newFieldMappings)

Dan Patterson recently created an interesting blog page on geonet showing how numpy can be used to do clever things with a FeatureClass. This could be another way one could alter the field order.

But ideally ESRI should make their tools aware of field order...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.