AnsweredAssumed Answered


Question asked by cliveswan on Dec 29, 2015
Latest reply on Dec 29, 2015 by rastrauch

I need to automate a shapefile to feature class update. The problem is that the shapefile name and output (feature class) are not the same.

So I need to hard code the shp & features.


I have a loop that works, printing out the shapefile names.

The code fails when I try to use the arcpy.CopyFeatures_management function.

Can anyone see what is causing the arcpy.CopyFeatures_management function to fail??

Would appreciate a suggestion to resolve the issue.


import arcpy
import glob
import os
import sys
import csv
import time
import smtplib
import shutil
import ftplib

sdeConnection = arcpy.env.workspace = r"C:\database_connections\GIST.sde"
outWorkspace =sdeConnection

datadir = arcpy.env.workspace = r"\\server1\ER Shares\Highway_Layer_Update" ## URL works

    #check file exists here
    fcList = arcpy.ListFeatureClasses()

    ## Feature classes are hard coded
    ## Feature classes are hard coded
    for i in fcList:
        if i == "Bus Stops.shp":
            #outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
            #arcpy.CopyFeatures_management(shapefile, outFeatureClass)
            print i  ## NO shp
            fcnew = "GISADMIN.KCC_BUSSTOPS_NEW"
            outFeatureClass = os.path.join(outWorkspace, fcnew )
            arcpy.CopyFeatures_management(i,  outFeatureClass)
        elif i == "Cluster_sites_2014.shp":
            print i            ## Prints shp
            fcnew = "GISADMIN.KCC_KHS_CLUSTERS_2014_NEW"
            outFeatureClass = os.path.join(outWorkspace, fcnew )  ## Fails
            arcpy.CopyFeatures_management(i, outFeatureClass)
            print "No file"
    print ("No File found program terminated")  ## This is printed out


Message was edited by: Dan Patterson I formatted your code to make it easier to read... use the syntax highlighting ... >> ... and select Python