1

I have an locations shapefile that I am trying to overwrite. I have enabled the geoprocessing options to overwrite all geoprocessing operations. I opened the analysis tool that I created the original locations shapefile from and tried to rerun the tool with the same input and output. I am receiving two errors, 1, Warning 000725, indicating that the output files already exist and 1 Error 000723, indicating that the input files in my table of contents does not exist or is not supported. Any thoughts?

Tiffany Morris
  • 323
  • 3
  • 15

2 Answers2

1

There are many possible causes for the second warning about input not existing; maybe you could provide more information.

I am familiar with the first warning about output already existing. This is often because the environment setting "env.overwriteOutput" is not working properly. The typical work-around is for your script to check for the existence of your output and to delete the output if it exists before generating new output. Here is a simple example involving creating a backup of a feature class:

import os
import arcpy as a
from arcpy import env

fc = "name_of_your_feature_class"
fc_dir = r"path_to_your_feature_class"
out_dir = r"directory_to_copy_feature_class_to"

env.workspace = fc_dir
env.overwriteOutput = True

in_fc = os.path.join(fc_dir, fc)
out_fc = fc + "_backup"

try:
    a.FeatureClassToFeatureClass_conversion(in_fc, out_dir, out_fc)
except a.ExecuteError: #In case env.overwriteOutput does not work
    print "env.overwriteOutput malfunctioning: attempting work-around..."
    try:
        if a.Exists(out_fc):
            a.Delete_management(out_fc)
            a.FeatureClassToFeatureClass_conversion(in_fc, out_dir, out_fc)
            print "Work-around complete."
    except Exception as e:
        print "Work-around failed."
        print e

I hope this helps!

Tom

TomAdair
  • 321
  • 1
  • 10
1

Wanted to post a comment to @TomAdair's response, but wanted to get formatting right. Maybe a little more concise is to just try to delete and let that part fail.

try:
    a.Delete_management(out_fc)
except:
    pass

a.FeatureClassToFeatureClass_conversion(in_fc, out_dir, out_fc)
Roland
  • 499
  • 6
  • 16