0

I am unable to get an output using arcpy.analysis.Select() where the field aliases and names are preserved.

from arcpy.analysis import *

Select("Input.shp", "Output.shp", "FLOOR= 0")

The codeblock above gives columns names based on the table name such as Input_1, Input_2, Input_3, etc... is there a workaround for this?

  • 2
    What is your Input? A shapefile or geodatabase? – Midavalo Sep 15 '17 at 21:35
  • shapefile, would it make a difference? – Micks Ketches Sep 15 '17 at 21:39
1

Shapefiles don't store aliases. If you're OK with your new field names being close to your aliases, but restricted to shapefile field name limits, you might be able to get close by copying the output shapefile to a geodatabase feature class, renaming the fields with AlterField_management, and exporting it back out to shapefile.

  • Where is the tabular data associated with a shapefile stored then? – Micks Ketches Sep 15 '17 at 21:55
  • 2
    In the dbf file, which only stores a field name, but not an alias. – Marc Pfister Sep 15 '17 at 21:58
0

As an update to this issue, the solution is listed here: http://resources.arcgis.com/en/help/main/10.2/index.html#//001w00000008000000

You basically need to set arcpy.env.qualifiedFieldNames = False as it is True by default, this will preserve all original field names.

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.