2

I have multiple fields in a feature. I need to copy multiple (5-6) attributes of a polyline to a different polyline in the same feature. To make things worse, I will have around 30 different polyline to copy the attributes to.

In this answer, I found copying of all attributes of a polyline to a different polyline. The only difference is that, I need to copy specific (multiple) attributes of a polyline to multiple polylines in the same feature.

  • 5-6 attributes from a single polyline to 30 others in the same feature – pnkjmndhl Apr 20 '17 at 13:26
2

You could do it like this (maybe not the easiest way though) but be careful, you cant undo the changes:

Open the attribute table and select the single row you wish to copy from. Using the Python window execute this code to store the attributes in the variable attributes:

with arcpy.da.SearchCursor("Points12345",['Field1','Field2','Field3']) as cursor:
    for row in cursor:
        attributes=row

Clear the selection and then Select only the rows you wish to paste the attributes into and execute this code:

with arcpy.da.UpdateCursor("Points12345",['Field1','Field2','Field3']) as cursor:
    for row in cursor:
        row=attributes
        cursor.updateRow(row)

You need to change "Points12345" and the field names (and add/remove fields) to match your data.

Before: enter image description here After: enter image description here

  • Since, I have to do it multiple times, I am trying to change your code to Script (with the name of the fields, source polyline, destination polylines as parameters). I will let you know if it does or doesnot work. – pnkjmndhl Apr 20 '17 at 13:42
  • 1
    Yes, that worked, I combined both the codes to one. When I ran the code, the required attributes of the first selected polyline was copied to the rest. – pnkjmndhl Apr 20 '17 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.