Skip to content

Instantly share code, notes, and snippets.

@hunterwei
Created January 18, 2018 00:01
Show Gist options
  • Save hunterwei/6b68f9ddfe4d3e0ebc1c5fe51a160f24 to your computer and use it in GitHub Desktop.
Save hunterwei/6b68f9ddfe4d3e0ebc1c5fe51a160f24 to your computer and use it in GitHub Desktop.
ArcPy snippet to copy values from one feature class to another feature class
import arcpy
rows = arcpy.InsertCursor("TARGET_FEATURE")
sourcerows = arcpy.SearchCursor("SOURCE_FEATURE")
fields = arcpy.ListFields("SOURCE_FEATURE")
for sourcerow in sourcerows:
row = rows.newRow()
for field in fields:
if field.name != "OBJECTID":
row.setValue(field.name, sourcerow.getValue(field.name))
rows.insertRow(row)
del fields
del sourcerows
del row
del rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment