0

I have 3 shapefiles belongs to one state "District", "Mandal", "Village".

These three shapefiles have the same fields like DName, MName, VName.

I want to update all field in all shapefiles at a the same time with ArcPy update cursor.

I am new for ArcPy i tried but getting for single shapefile.

2

You'll just need a for loop to iterate through multiple items (in this case, strings of the paths to your shapefiles) if you wish to perform the same procedure on multiple items.

A basic template:

import arcpy

#Paths to shapefiles
distFc = r"C:\test\example\district.shp"
mandalFc = r"C:\test\example\mandal.shp"
villageFc = r"C:\test\example\village.shp"

#Create list of shapefiles
shapefiles = [distFc, mandalFc, villageFc]

#iterate through each shapefile with a for loop
for shp in shapefiles:
    #Create update cursor
    with arcpy.da.UpdateCursor (shp, ["DName", "MName", "VName"]) as cursor:
        #iterate cursor
        for dName, mName, vName in cursor:
            # code goes here

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.