Select to view content in your preferred language

Find and replace a character within a field in geodatabase

794
4
07-08-2014 02:17 AM
PeterVersteeg
Frequent Contributor

Hello I have a geodatabase with many features with tables.

I use a tool that splits a features by attribute

(build by Dan_Patterson,    http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=37AEB018-1422-2418-A036-CA6D9...).

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
DuncanHornby
MVP Notable Contributor

Peter,

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.

Duncan

0 Kudos
HåvardMoe
Deactivated User

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...

PeterVersteeg
Frequent Contributor

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
DanPatterson_Retired
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.