0

I have to edit the Name of the feature classes in my databank by deleting the Suffix part called "_AAA_VV". I am not pro in ArcPy but prepared something which does not work.

Can you help to find my mistake?

import arcpy, os
database = r'C:...\Data_test.gdb' 
try:
for dataset in datasets:
 arcpy.env.workspace = os.path.join(database,dataset)
 features = arcpy.ListFeatureClasses()
 for feature in features:
 # feature.replace('_AAA_VV,'')
 feature.split('_AAA_VV,1)[0]
except Exception as e:
print("Found an error - {0}".format(e))
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Nov 22, 2018 at 9:46

1 Answer 1

4

This should work

import arcpy
database = r'C:...\Data_test.gdb'
arcpy.env.workspace = database
datalist = arcpy.ListDatasets("*", "Feature")
for data in datalist:
 try:
 features = arcpy.ListFeatureClasses("*", "ALL", data)
 for feature in features:
 split = feature.split('_AAA_VV')
 arcpy.Rename_management(feature, split[0])
 except IndexError:
 print('Error found in feature - {0}'.format(feature))
answered Nov 22, 2018 at 10:01
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.