Last active
October 5, 2017 05:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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