Find and Replace?

1133
2
08-21-2017 02:41 PM
deleted-user-iwYtitJHBIyn
New Contributor II

Hello,

I need to find an easy way to update multiple values in a file geodatabase attribute table.  These same values will need to be found in the table and replaced with values that I have within a list on a monthly basis so I would very much like to make this an automated function.

Is this possible?

My abilities are not quite there yet when it comes to programming so any assistance or guidance someone can provide would be extremely valuable.

Thank you in advance.

Jeff

0 Kudos
2 Replies
MicahBabinski
Occasional Contributor III

Hi Jeff,

How many attribute tables, and how many values do you need to update on a monthly basis? There's a find and replace tool which you can use if it's only a few values in a limited number of tables:

How To: Replace the text in multiple fields within an attribute table using the Find and Replace too... 

If you want something more automated, here's what I'd do:

  1. Create a table with two columns: old_value and new_value, which contain the old value and the one you want to update it with
  2. Create an empty Python dictionary, and use an arcpy DA search cursor (SearchCursor—Help | ArcGIS for Desktop) to populate it with the keys being the old text and the corresponding values being the new text.
  3. For each file geodatabase attribute table you want to update, use an arcpy DA update cursor (UpdateCursor—Help | ArcGIS for Desktop) to comb through each table and update the values based on the lookup dictionary.

That sounds like it will increase your productivity and so would be a good first forray into arcpy.

Good luck!

Micah

0 Kudos
deleted-user-iwYtitJHBIyn
New Contributor II

Hi Micah,

Thank you for replying to my message.

Typically it will be just one attribute table that will require edits.  The number of fields that will require records to be modified will range from just 1 to 2.  Not that many.

The number of values to update on a monthly basis is an additive process.  It may start out with 3 values to change, but then the following month the same 3 values will still need to be changed and perhaps 4 more to add to the list.  The list will grow as we move along with some dropping off and others being added to the process.

Thank you for the automation suggestion.  I will definitely look into it.  Hopefully the learning curve isn't too steep.

Jeff

0 Kudos