Hey All,
I'm sure I'm doing something very obvious that I'm missing, when using arcpy and the CopyFeatures tool, I'm running into an issue where it removes everything in a field name after an underscore. Here are some screenshots:
Before:
After:
I saw in the Copy Features geoprocessing tool I can enable "Maintain fully qualified field names" but I see no way to do this in Python, is there a way?
arcpy.management.CopyFeatures(NID_Layer, output_fc)
Thanks in advance!
Cody
Solved! Go to Solution.
I was able to find a way around it, I had to use the append tool along with a new source on the actual output of structure_name that I wanted to use, I've attached a screenshot of what I did. I converted the actual geoprocessing tool to Python using the drop down next to run and then input my variables and everything worked! (This was after the Copy Features, as structure is cut down)
Cody
If the output is a Shapefile, they can only have field names 10 characters long, max. Anything longer gets cut off.
Use a geopackage or mobile geodatabase instead if you need to easily share the data and maintain the field names.
Oddly enough, it immediately converts the feature layer into a shapefile after this copy occurs, the main reason for this is to eventually stack the information into a feature class, but since the field names are different, it doesn't allow that to happen. Would you know of a way to to map this structure_ field to structure_name when using the append tool? Any type of change I've made has just placed "Null"
field_mappings = arcpy.FieldMappings()
field_map_ipid = arcpy.FieldMap()
field_map_clli = arcpy.FieldMap()
field_ipid = arcpy.Field()
field_ipid.name = "ipid"
field_clli = arcpy.Field()
field_clli.name = "structure_"
field_map_ipid.addInputField(output_fc, "ipid")
field_map_clli.addInputField(output_fc, "structure_")
field_mappings.addFieldMap(field_map_ipid)
field_mappings.addFieldMap(field_map_clli)
This is my attempt so far
I was able to find a way around it, I had to use the append tool along with a new source on the actual output of structure_name that I wanted to use, I've attached a screenshot of what I did. I converted the actual geoprocessing tool to Python using the drop down next to run and then input my variables and everything worked! (This was after the Copy Features, as structure is cut down)
Cody
Nice work!