I appreciate the code - but being the novice that I am I can't get it to work. Likely missing some small thing. First let me show you the code I wrote last night with the addition of two of your lines from the code you gave me.
import arcpy
arcpy.env.overwriteOutput = True
# set table path
intable = "C:/Project/Project.gdb/DeltaWL"
shapefile="C:/Project/Project.gdb/model_nodes"
spField = "SP"
deltaField="Delta"
cellidField="Cell_ID"
rows = arcpy.SearchCursor("C:/Project/Project.gdb/DeltaWL", "SP"=='1', "", "SP; Delta; Cell_ID")
currentSP = ""
fields= arcpy.ListFields(intable)
fieldinfo = arcpy.FieldInfo()
for row in rows:
if currentSP !=row.SP:
currentSP = row.SP
currentSP=row.getValue(spField)
queryString=currentSP
for field in fields:
if field.name == "SP":
fieldinfo.addField(field.name, "SP_"+str(currentSP), "VISIBLE", "")
elif field.name == "ROW":
fieldinfo.addField(field.name, field.name, "HIDDEN", "")
elif field.name == "COL":
fieldinfo.addField(field.name, field.name, "HIDDEN", "")
elif field.name =="Delta":
fieldinfo.addField(field.name, "Delta_"+str(currentSP), "VISIBLE", "")
elif field.name =="Cell_ID":
fieldinfo.addField(field.name, "Cell_ID", "VISIBLE", "")
arcpy.MakeTableView_management (intable, "out_" +str(currentSP), "", "", fieldinfo)
arcpy.AddJoin_management(shapefile,"ID", "out_" +str(currentSP), "Cell_ID","KEEP_COMMON")
#save feature layer with joined data
arcpy.CopyFeatures_management(shapefile, "Joined_"+field)
print queryString
print "made table"
-----
this now gives me the following error:
The value cannot be a feature class
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Raster Catalog Layer.
ERROR 000840: The value is not a Mosaic Layer.
WARNING 000970: The join field ID in the join table model_nodes is not indexed. To improve performance, we recommend that an index be created for the join field in the join table.
Failed to execute (AddJoin).
I tried the code you gave me and made a few modifications based on names and such:
import arcpy
arcpy.env.overwriteOutput = True
from arcpy import env
import os
arcpy.env.workspace = r"C:\Project\Project.gdb"
model_nodes = "model_nodes"
spField="SP"
dataTable = "DeltaWL"
#Create list of feature classes in current workspace
#ASSUMPTION: feature class layers share part of name with SP value: eg. layer_1 for SP=1
fcLst = arcpy.ListFeatureClasses()
#loop through possible classes and for each create TableView
for sp in range(1,11): #range (1 to 10)
whereClause = 'spField = ' + str(sp)
arcpy.MakeTableView_management(dataTable,"Delta_WL" +str(spField), whereClause)
#for corresponding feature class in workspace create Feature Layer
fcName = model_nodes + str(spField) #name of input Feature Class
if fcName in fcLst:
inputFLName = model_nodes + str(spField) #name of temporary Feature Layer
arcpy.MakeFeatureLayer_management(fcName, inputFLName)
#join data from Table View with 'Add Join' tool
#"KEEP_COMMON" parameter cause preserving only maching records
arcpy.AddJoin_management(inputFLName,"ID", Delta_WL + str(spField), "Cell_ID","KEEP_COMMON")
#save feature layer with joined data
arcpy.CopyFeatures_management(inputFLName, "Joined_"+fcName)
print "Joined_" + fcName + " created"
----
with this I don't get an error - but nothing is added to my geodatabase. What am I missing?