Select to view content in your preferred language

Overwrite input not working

381
1
Jump to solution
09-10-2018 01:24 PM
by Anonymous User
Not applicable

Below is the script I'm trying to run but it will not overwrite the input layer. I'm not sure what I'm doing wrong.....

# Import arcpy module
import arcpy, datetime, os
arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"G:\****************************\Files"

arcpy.MakeFeatureLayer_management("ApprovedApproachesCy2.shp", "ApprovedApproachesCy2")

arcpy.SelectLayerByAttribute_management("ApprovedApproachesCy2", "NEW_SELECTION", "Culvert_Re = 'yes' AND Date_Appro = CURRENT_DATE")

arcpy.CopyFeatures_management ("ApprovedApproachesCy2", "ApprovedApproachesCy2")
                                       
print "Complete"

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

I have seen that before.  I suspect that the object you are trying to overwrite hasn't been 'released' during the process.

You may have to add a 'Delete' (not tested)

arcpy.MakeFeatureLayer_management("ApprovedApproachesCy2.shp", "temp")

arcpy.SelectLayerByAttribute_management("temp", "NEW_SELECTION", "Culvert_Re = 'yes' AND Date_Appro = CURRENT_DATE")

arcpy.CopyFeatures_management ("temp", "ApprovedApproachesCy2")
arcpy.Delete_management ("temp")
                                       
print "Complete"














anagement

View solution in original post

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

I have seen that before.  I suspect that the object you are trying to overwrite hasn't been 'released' during the process.

You may have to add a 'Delete' (not tested)

arcpy.MakeFeatureLayer_management("ApprovedApproachesCy2.shp", "temp")

arcpy.SelectLayerByAttribute_management("temp", "NEW_SELECTION", "Culvert_Re = 'yes' AND Date_Appro = CURRENT_DATE")

arcpy.CopyFeatures_management ("temp", "ApprovedApproachesCy2")
arcpy.Delete_management ("temp")
                                       
print "Complete"














anagement

0 Kudos