Skip to content

Instantly share code, notes, and snippets.

@cindygis
Last active October 5, 2017 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cindygis/f7a1d0334665babf4552f336d57f7bfa to your computer and use it in GitHub Desktop.
Save cindygis/f7a1d0334665babf4552f336d57f7bfa to your computer and use it in GitHub Desktop.
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 https://stackoverflow.com/a/199215
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