AnsweredAssumed Answered

Populate Field with partial data from another local field

Question asked by kdegraf4 on Jul 30, 2012
Latest reply on Jul 31, 2012 by kdegraf4
I have a field (HUC12_ID) that I want to populate with data from another field (VALUE) which is in the same table. The problem is I only want to use part of the data from the VALUE field. I wrote a script to to try and accomplish this but it keeps giving me this error:

Runtime error <type 'exceptions.RuntimeError'>: ERROR 999999: Error executing function.

I have written several variations of the script but all have returned the same error. Could someone give me a hint as to why my script is not doing what I want it to? I just started learning python last weekend and am at my wits end with this thing lol.

 import arcpy  # set up environment arcpy.env.workspace = "C:/scratch_workspace/test.gdb/" arcpy.env.overwriteOutput = True  # Create list of tables in b1_scratch.gdb  B1S = arcpy.ListTables() # Create update cursor object uc = arcpy.UpdateCursor(B1S)  Value = row.getValue(VALUE) # If the value meets the requirements for a if statement # I want to take a set number of characters from this field and # use it to populate the HUC12_ID field... for row in uc:     if (row.VALUE < 100000):         row.HUC12_ID = Value[:1]         # VB script input for fieldcalc "Left(CStr([VALUE]),1)"              if (row.VALUE >= 100000) and (row.VALUE < 1000000):         row.HUC12_ID = Value[:2]         # VB script input for fieldcalc "Left(CStr([VALUE]),2)"              if (row.VALUE >= 1000000) and (row.VALUE < 10000000):         row.HUC12_ID = Value[:3]              # VB script input for fieldcalc "Left(CStr([VALUE]),3)"              if (row.VALUE >= 10000000) and (row.VALUE < 100000000):         row.HUC12_ID = Value[:4]         # VB script input for fieldcalc "Left(CStr([VALUE]),4)"              if (row.VALUE >= 100000000):         row.HUC12_ID = Value[:5]         # VB script input for fieldcalc "Left(CStr([VALUE]),5)"              rows.updateRow(row) # del will delete the cursor object "uc" to prevent file locking issues... del uc