I have different month folders, each folder contain a shapefile called, For January folder Merged001.shp, For FEBRUARY Merged002.shp so on,
That shapefile having one field name 'Solar', and i am trying to delete specific value from Solar field or we can say whichever value < 15 its will be deleted from Solar field (which is < 15.)
I have made a script to loop through all the month folder and read it the shapefile's Solar field and delete it < 15 value.
Below is my script and error massage
import arcpy, os, calendar from arcpy import env from arcpy.sa import * arcpy.CheckOutExtension("Spatial") topWorkspace = r'D:\Delete_Test' env.workspace = topWorkspace env.overwriteOutput = True months = {calendar.month_name[i].upper(): str(i).zfill(3) for i in range(1, 13)} for folderPath in arcpy.ListWorkspaces(): baseName = os.path.basename(folderPath).upper() if baseName in months: monthNumber = months[baseName] arcpy.env.workspace = folderPath shapeFiles = (arcpy.ListFeatureClasses('Merged_*.shp')[0]) print shapeFiles with arcpy.UpdateCursor(shapeFiles, ["Solar"]) as cursor: for row in cursor: if row [0] < 17: cursor.deleteRow(row) del row error massage :
Traceback (most recent call last): File "<module2>", line 19, in <module> AttributeError: __exit__
rows =line is 'outside' thefor folderPathblock?with arcpy.UpdateCursor(shapeFiles, ["Solar"]) as cur:for row in cur:if row.Solar < 17:rows.deleteRow(row)del row