I am trying to join a shapefile to a dbf table then create a new shapefile with certain fields. Feature class and table are on SDE.
I am having trouble putting it together. Any help would be great, thanks!
My code
# Join a table to a featureclass and select the desired attributes
# Import system modules
import arcpy
from arcpy import env
# Set environment settings
env.workspace = "C:/TEMP"
env.qualifiedFieldNames = False
# Set local variables
inFeatures = "**\\**.sde\\vector.DBO.**\\vector.DBO.**"
layerName = "TAX_layer"
layerName2 = "TAX_layer2"
joinTable = "**\\**.sde\\Vector.DBO.**"
joinField = "ACCOUNT"
joinField2 = "Acct"
outFeature = "TAX_ADDMIN.shp"
outFeature2 = "TAX_ADDMIN2.shp"
expression = "ACCOUNT", "OwnerName", "Address", "City" , "State", "ZipCode"
outLocation = "C:/temp"
# Create a feature layer from the vegtype featureclass
arcpy.MakeFeatureLayer_management (inFeatures, layerName)
# Join the feature layer to a table
arcpy.AddJoin_management(layerName, joinField, joinTable, joinField2)
# Copy the layer to a new permanent feature class
arcpy.CopyFeatures_management(layerName, outFeature)
# Create a feature layer from the vegtype featureclass
arcpy.MakeFeatureLayer_management (outFeature, layerName2)
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(layerName2, outLocation,
outFeature2, expression)
My error.
Traceback (most recent call last):
File "C:\GIS\Python Scripts\JoinField Example 2_2_1.py", line 41, in <module>
outFeature2, expression)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\conversion.py", line 1132, in FeatureClassToFeatureClass
raise e
RuntimeError: Object: Error in executing tool