Update Cursor to enter name string in attribute field

388
2
Jump to solution
07-25-2013 04:43 AM
JacobDrvar
New Contributor II
All,

I need to modify my script to have the user's name entered into the MAPPER attribute field.  Currently, the script enters inputName into the attribute field.  I have a Parameter setup to Enter YOUR name as a string, but the script overwrites the name entered.  I want the Enter YOUR Name string the value to be entered into the attribute table, not the inputName.  My script is shown below.  inputName is listed as the 2nd string, since this is only part of my script.  I have another string set to 0.

#Import import arcpy  #Name Variable inputName = arcpy.GetParameterAsText(1)  #Permits the user to enter their name into the MAPPER field try:          cursor = arcpy.da.UpdateCursor("Parcels", ["MAPPER"])  for row in cursor:   cursor.updateRow(["inputName"])  arcpy.AddMessage("name entered")  del row  del cursor  except:  print arcpy.GetMessages()
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Frequent Contributor
Replace your entire loop with this.

    for row in cursor:         row[0] = inputName         cursor.updateRow(row)


Hopefully you see where your code went wrong.

View solution in original post

0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
Replace your entire loop with this.

    for row in cursor:         row[0] = inputName         cursor.updateRow(row)


Hopefully you see where your code went wrong.
0 Kudos
JacobDrvar
New Contributor II
Matt,

I was telling the script to enter the string "inputName".  It would "inputName" into the attribute field, instead of the name entered.
Thanks for your help.
0 Kudos