I am trying to build a simple tool that concatenate values from two fields, and recording it in newly created field - everything within the same table. This tool should work with any shapefile, concatenate any type of fields and create a field (with name chosen by user). My problem is how to pass value of 'new_field_name" in to row.getValue() (second last row of the code). Or any other ways of doing the same?
import time, arcpy
startTime = time.clock()
print "Start"
shapefile = arcpy.GetParameterAsText(0)
field_name_1 = arcpy.GetParameterAsText(1)
field_name_2 = arcpy.GetParameterAsText(2)
new_field_name = arcpy.GetParameterAsText(3)
new_field_length = arcpy.GetParameterAsText(4)
separator = arcpy.GetParameterAsText(5)
arcpy.env.workspace = shapefile
arcpy.env.overwriteOutput = True
arcpy.AddField_management(shapefile, new_field_name, "Text", "", "", new_field_length)
cur = arcpy.UpdateCursor(shapefile)
for row in cur:
row.getValue() = (str(row.getValue(field_name_1)) + separator + str(row.getValue(field_name_2)))
cur.updateRow(row)