0

I wanted to copy a specific row of a table to another new table. So what I did was,

  1. copy the data of the row to a particular Array called c[].
  2. Write them to a file Geodatabase table called Dead_T

I have completed the 1st step. Now I want to do the 2nd step. I have tried the following code for step 2, but it is not working. Can anyone tell me the mistake that I have made here? (Here filedname is one of the names of columns available in the table Dead_T)

Dead_T='C:\Users\Shanaka\Desktop\TL _HAndling\cad\Cad_Data.gdb\DD_IF'
with arcpy.da.UpdateCursor(Dead_T, "filedname") as cursor1:
 for row1 in cursor1:
 row1[0] = c[0]
 arcpy.AddMessage ("done")
 cursor1.updateRow(row1)
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 22, 2018 at 14:56
1
  • 3
    UPDATE changes an existing row. INSERT creates a new one. Your c variable is not defined. Do you really want to clobber every row with the first element of the array? Commented Nov 22, 2018 at 15:04

1 Answer 1

1

As mentioned in the comment, you must use an insert cursor here because update cursor work for changing the values of existing rows:

# I assume that DT and c are defined, the fieldnames exist in DT and c is a list of list with two item.
with arcpy.da.InsertCursor(DT, ("fieldname1","fieldname2")) as cursor:
 for row in c: #take each row of c
 cursor.insertRow(c) 
fatih_dur
5,0232 gold badges19 silver badges36 bronze badges
answered Nov 22, 2018 at 15:19
1
  • Thanks a lot. This really helps me. It is working now Commented Nov 25, 2018 at 6:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.