I have 2 feature classes (FC) that I am merging together and then performing some field calculations on.

The 1st FC has 100k+ records in it, and the second FC is a blank FC that I'm using as a template. I need to merge the two FC's together and then field calc the values from FC1 into FC2.
The problem with FC2 is that the fields are required to often be of a different type. For example, in FC1 field "PID" is a double and in FC2 "PIN" is a string. I need to calculate the values of "PID" into "PIN" with a prefix of "139-". This pattern is repeated several times with different fields.

My simple code example:

data = r"C:\Temp\Test.gdb\PAR_PROPINFO_SCO_VW2"    
template = r"C:\Temp\Test.gdb\Template"    
out = r"C:\Temp\Test.gdb\Scott_CO"    
qry= '"139-"' + "+'PID'"    

In this particular instance, qry threw a syntax error.

If I just use:


I get a type mismatch error.

Since I'm on Arc 10.0, I was trying to avoid a cursor with the amount of records involved.

This process will run daily and the # of records will only increase. I was thinking I could just get away with a brute force merge and calc method. However, I run into type mismatches. I thought field mappings, but that is beyond my current level.

1 Answer 1


You're trying to concatenate a string with a double, which can't be done. You need to operate with the same data types, so you can cast you numerical data types to string. You can use the built in function, str() and then contatenate, but I'd suggest string formatting, which automatically casts variables to strings and is generally faster, which is important in your case as a few microseconds will add up over the course of thousands of records.





As an arcpy script:

qry = '"139-{}".format(!PID!)'
arcpy.CalculateField_management(out, "PIN", qry, "PYTHON")
  • I got an error "Zero length field name in format". I think it is related to the fact that ArcGIS runs on Python 2.6.
    – jmm
    Commented Sep 27, 2013 at 13:44
  • qry = '"139-{0}".format(!PID!)'
    – jmm
    Commented Sep 27, 2013 at 13:45
  • Ahh, string formatting must have been changed from Python 2.6 - > 2.7. Sorry about that.
    – Paul
    Commented Sep 27, 2013 at 15:08
  • What is the significance of the zero {0}?
    – jmm
    Commented Sep 27, 2013 at 19:15
  • 1
    It's an index number referring to what variable in format() to reference. In Python > 2.7, it's not needed. Assuming x = 123 and y = 456, "{1} + {0} = {2}".format(x,y,x+y) would output '456 + 123 = 579'.
    – Paul
    Commented Sep 27, 2013 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.