Copy/Paste Attribute Values, Same Table

4974
5
Jump to solution
02-06-2014 01:10 PM
SlatonMcCauley
New Contributor
I am trying to figure out how to copy an attribute value of a point and paste it into a field for another row in the same table. I wanted to create an add-in, or something that would help speed up having to do this for thousands of points, but am stuck on how to access a specific attribute field for a selected point using Python. (My Python skills currently need improvement, at best.) Could anyone offer a nudge forward?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Rachel,

You can do this using the field calculator.  You will just need to right-click on the new field > Field Calculator > double-click the field you want to calculate the values from.  This will add the field to the code box below.  Then click OK.  Take a look at the below example.  The field values from field FCC will be calculated to FCC_new.

screen.png

View solution in original post

5 Replies
RachelBaca
New Contributor II

I'm glad you asked as that is what I am trying to do.  I've created a new field in a table that needs the attribute values from another field in the table.   I know that we can use the Field Calculator, but need to use either VB or Python to write an expression.   I know in the older command line ARcInfo, it was as simple as writing  calc field2 = field1.  But that didn't work with VB,   All the other help references and discussions involved transfering attribute data from one table to another, which isn't what we need to do.

Have you tried using the Python function replace?

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Rachel,

You can do this using the field calculator.  You will just need to right-click on the new field > Field Calculator > double-click the field you want to calculate the values from.  This will add the field to the code box below.  Then click OK.  Take a look at the below example.  The field values from field FCC will be calculated to FCC_new.

screen.png

RachelBaca
New Contributor II

Thank you.   Worked perfectly.

0 Kudos
SlatonMcCauley
New Contributor

Thank you for your response! I couldn't get the field calculator to work for what I needed at the time because the field calculator copies the values into different cells in the same row in the table. I needed a way to copy the values from two cells in one row of the table and paste into two different cells in a ‌different‌ row in the table. It would have been easier if it were a simple shift up or down a number of rows, but it wasn't. Either way, I found a work-around and wanted to let you know I appreciate your response!

0 Kudos
RichardFairhurst
MVP Honored Contributor

Stanton:

What want to do is done using a python script with a Search cursor to read the values and store them in a dictionary based on a key value that will be in the other row(s), then use an update cursor to write the values into the other columns by matching the key value in each updated row to the dictionary.  I assume there has to be some sort of attribute relationship, spatial relationship, or row order pattern that would create an association between records, because no automated matching is possible without a preexisting relationship of some kind between the rows being read and the rows being written.  The script can include additional logic to control the update, such as only writing to rows with Null values or some other criteria.  A script like this can typically read and update 100k rows in about 1 to 2 minutes if the dictionary key is based on an attribute relationship.

0 Kudos