I have created a new shapefile and want to add shape attribute from another existing shapefile. It will be a recursive process with update of shape attributes of new shapefile (ofc) more than 2 times. Any help is appreciative. Following is what I am trying to make work:

Import arcpy
ofc = "C:/outFC.shp"
ifc = "C:/inFC.shp"
fields = arcpy.ListFields(ifc,"*","ALL")
for f in fields:
    shape = f.Shape
    query = '"Shape" = \'' + str(shape) + '\''
    cur = arcpy.UpdateCursor(ofc,query)

del f, fields

Diagram: I want to get FID (0) from first table and add it to second table of new shapefile and only need FID, Shape, and id fields in second table.

enter image description here enter image description here

  • Have you investigated Join Field?
    – PolyGeo
    Mar 11, 2013 at 22:33
  • Join field runs ok but don't update attributes based on join table layer. Further, I need only one row of interest from existing shapefile to be written to new shapefile.
    – Ibe
    Mar 11, 2013 at 23:17
  • Can you clarify your requirements by adding a diagram to your Question, please? If you are only wanting a subset to be updated perhaps think about Select By Attribute and Calculate Field - but without a diagram I'm taking stabs in the dark.
    – PolyGeo
    Mar 12, 2013 at 0:01
  • It sounds like you need to do a select and then paste into your destination feature class, using python of course, but this is the essence of what you want to do. Since there are a couple of different ID fields listed, it would help if you specified the desired source ID field. For the selection of FID's, are there specific ones that you want to copy, or all of them, or based on an attribute selection? This information would be useful in structuring the first part of the script to feed the loading process into the target shapefile. Mar 12, 2013 at 0:43
  • Right. I want to select first FID from the parent layer and paste it into target layer. Above parent table will change after each run of geoprocessing and I want to get first row FID every time and paste it to target layer. So the number of rows for FID, Shape, and id fields in target layer will keep growing until required.
    – Ibe
    Mar 12, 2013 at 0:53

1 Answer 1


So, you want the FID from the first table to be in the Id column in the second table? And you are inserting a new row into the second table, not updating an existing row in that table?

import arcpy
ofc = "C:/outFC.shp"
ifc = "C:/inFC.shp"
searchcursor = arcpy.da.SearchCursor(ifc,("OID@","SHAPE@"))
firstrow = searchcursor.next()
insertcursor = arcpy.da.InsertCursor(ofc,("Id","SHAPE@"))
del firstrow,insertcursor,searchcursor

OID@ is a token representing the ObjectID field (so you don't have to worry if it is FID, OBJECTID, or some other value). SHAPE@ is a token representing the shape field.

Order matters. That is why I made the search cursor ("OID@","SHAPE@") and the update cursor ("Id","SHAPE@"). That way, the fields map appropriately to each other.


Your Answer

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

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