Deleting file locks in ArcPy?

المشرف العام

Administrator
طاقم الإدارة
I did not realize that I should have been deleting cursors after accessing attribute tables until today. Up until now I never did this, but I've noticed that there are lots of file locks after my script runs (I presume it was a bad practice on my part to begin with). ArcGIS 10 help tells me that I should use the following code:

# Delete cursor and row objects to remove locks on the data # del row del rowsI'm doing that in the following function:

# calculate areasdef area_calc( shapefile ): "calculates geometric properties of each building" # loop through attribute table Rows = ARCPY.UpdateCursor( shapefile ) for row in Rows: geom = row.Shape polyArea = geom.area row.setValue( perimName, 0 ) # set to zero polyPerim = geom.length row.setValue( areaName, polyArea ) # update area value row.setValue( perimName, polyPerim ) # update perimeter value Rows.updateRow(row) # Delete the row and cursor del row del Rows ARCPY.AddMessage( 'Area and Perimeter calculated for each polygon' )However, when I do that I get the following error message:

Traceback (most recent call last): File "LoopModuleBuildingAnalysis.py", line 9, in import ConstructionMaterialPhase1 File "D:\Code\AnalysisPhase1.py", line 101 del row ^SyntaxError: invalid syntaxPress any key to continue . . . Any suggestions what I should be doing?



أكثر...
 
أعلى