import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create(9.3) gp.OverWriteOutput = True # Set the workspace. List all of the folders within gp.Workspace = "C:\ZP4" fcs = gp.ListWorkspaces("*","Folder") #run spatial join on parcel.shp in each folder, then delete original and replace with "parceljoined" for fc in fcs: print fc try: gp.SpatialJoin_analysis(fc + "\\Parcels.shp", "C:\ESRI\ESRIDATA\USA\usa_zipcodes.shp", fc + "\\Parcelsjoined.shp",) gp.CalculateField_management(fc + "\\Parcelsjoined.shp", "SIT_ZIP", "[POSTAL]", "VB", "") gp.CalculateField_management(fc + "\\Parcelsjoined.shp", "SIT_CITY", "[CITYNAME]", "VB", "") gp.DeleteField_management(fc + "\\Parcelsjoined.shp", "Join_Count;Join_Cou_1;Join_Cou_2;POSTAL") gp.Delete_management(fc + "\\Parcels.shp") gp.Rename_management(fc + "\\Parcelsjoined.shp", "Parcels.shp") except Exception: print 'AddZip Error'
gp.Workspace = "C:\ZP4" and gp.SpatialJoin_analysis(fc + "\\Parcels.shp", "C:\ESRI\ESRIDATA\USA\usa_zipcodes.shp", fc + "\\Parcelsjoined.shp",) to gp.Workspace = "C:\\ZP4" and gp.SpatialJoin_analysis(fc + "\\Parcels.shp", "C:\\ESRI\\ESRIDATA\\USA\\usa_zipcodes.shp", fc + "\\Parcelsjoined.shp",)
import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create(9.3) gp.OverWriteOutput = True # Set the workspace. List all of the folders within gp.Workspace = "C:\\ZP4" gp.ScratchWorkspace = "C:\\ESRI\\temp_output" fcs = gp.ListWorkspaces("*","Folder") #run spatial join on parcel.shp in each folder, then delete original and replace with "parceljoined" for fc in fcs: print fc gp.AddSpatialIndex_management(fc + "\\Parcels.shp", "0", "0", "0") gp.SpatialJoin_analysis(fc + "\\Parcels.shp", 'C:\\ESRI\\ESRIDATA\\USA\\usa_zipcodes.shp', fc + "\\Parcelsjoined.shp", "") gp.CalculateField_management(fc + "\\Parcelsjoined.shp", "SIT_ZIP", "[POSTAL]", "VB", "") gp.CalculateField_management(fc + "\\Parcelsjoined.shp", "SIT_CITY", "[CITYNAME]", "VB", "") gp.DeleteField_management(fc + "\\Parcelsjoined.shp", "Join_Count;Join_Cou_1;Join_Cou_2;POSTAL") gp.Delete_management(fc + "\\Parcels.shp") gp.Rename_management(fc + "\\Parcelsjoined.shp", "Parcels.shp")