AnsweredAssumed Answered

Calculate Field management throwing field name error

Question asked by smkruzik on Apr 10, 2013
Latest reply on Apr 10, 2013 by smkruzik
I have been racking my brain for over a week now and no matter how I format my code, the arcpy.CalculateField_management line just will not run for me. 

The parts of the code for the operation are below.

arcpy.env.overwriteOutput = True env.workspce = "F:/GIS Data/Drivetesting.gdb" #mxd = arcpy.mapping.MapDocument("CURRENT") --used in the Arcpy environment #df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")  --used in the Arcpy environment Field = "PCode1" FC = "F:/GIS Data/Drivetesting.gdb/Carrier/Phone" MyField = Myfield = arcpy.ListFields(FC)[24] arcpy.MakeFeatureLayer_management(FC,"FC_lyr") ---------> tons of geoprocessing going on right here, but not included as not relevant to question (and saves space!)     mylist = []     # Iterate through the rows in the cursor       for item in Scursor:         a = (item.Frequency, item.PCode1,)         mylist.append(a)              mylist.sort()     mylist.reverse()     del mylist[1:]     applist = [x[1] for x in mylist]     applist.append(CellIDs.UNIQUE_ID)     applist.append(CellIDs.CellID)     print applist     PCode1 = str(applist[0])     PCode2 = str(applist[1])     PCode3 = str(applist[2])     Unitname = str(applist[3])     Columnname = '"Cellname1"'     print Cellname     print          arcpy.SelectLayerByAttribute_management("FC_lyr","SUBSET_SELECTION",' "PN1" = ' + PCode1 + " or \"PN1\" = " + PCode2 + " or \"PN1\" = " + PCode3)     arcpy.CalculateField_management("FC_lyr",Columnname,Unitname)

It throws

ERROR 000728: Field "Cellname1" does not exist within table Failed to execute (CalculateField).

I've tried writing out Cellname1, I've tried getting it through arcpy.listfields.  I've tried single quotes, double quotes, quoting the name it; I think I've tried it.  If anyone has any idea why this is happening, I would greatly appreciate some assistance as I am at my wits end here.  I know the field name exists as the 'print' is derived from the listfields function, and gives me "Cellname1" as my result. PLEASE HELP!