Skip to content

Instantly share code, notes, and snippets.

Last active October 5, 2017 05:54
What would you like to do?
How to insert a space between camel case, lest I ever forget again
# @date 05/10/2017
# @author Cindy Jayakumar
# Change the alias of feature classes to the
# title case version of the CamelCase name
# e.g. WaterPumpStation => Water Pump Station
import arcpy
import re
gdb = r"C:\Some\Arb\Folder\test.gdb"
def alterFCAlias(name):
return re.sub(r"\B([A-Z])", r" \1", name)
for root, _, fcs in arcpy.da.Walk(gdb):
for fc in fcs:
alias = alterFCAlias(fc)
arcpy.AlterAliasName(fc, alias )
print("{0} => {1}".format(fc, alias))
# @credit
import re
text = "ThisIsATest"
re.sub(r"\B([A-Z])", r" \1", text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment