Select to view content in your preferred language

Find and replace a character within a field in geodatabase

07-08-2014 02:17 AM
Occasional Contributor II

Hello I have a geodatabase with many features with tables.

I use a tool that splits a features by attribute

(build by Dan_Patterson,

Same field I use have a comma(,) in it and the tool Dan build cannot work with that.

For now I use the find and replace from the table options to make de "," a "_".

Is there a tool or script that will do the search and replace in my geadatabase for all features?

Thank you and Greetings Peter

0 Kudos
4 Replies
MVP Notable Contributor


I am not aware of a built in tool that can do this.

Can you program in Python?  You could create a cursor that cycles through a workspace then get the attribute table and run some sort of update cursor on the specified field.


0 Kudos
New Contributor III

Wouldn't it be possible to just use CalculateField with a small script code block to replace the commas?

Expression: "Recode(!FIELDNAME!)

ExpressionType = "PYTHON_9.3"

Code Block:

def Recode(input):

    output = input.replace(',', '_')

    return output

This could be wrapped in code to iterate feature classes and fields for an entire geodatabase if needed...

Occasional Contributor II

Thank you all for the fast reply. I will be on the lookout for your new build Dan. But in the meantime I will try the script and make a model.

0 Kudos
MVP Emeritus

Special characters will be incorporated in the next build...they were omitted to ensure that the backslash ( \ ) wouldn't be encountered during a Python query.