huffmanp

Arcpy CalculateField and change field type

Discussion created by huffmanp on Dec 11, 2012
I just had a quick Python script blow up on a line
arcpy.CalculateField_management(inshape, "PassNum", "PASS", "VB", "") 

because PassNum is typed SmallInteger 2 while PASS is typed LongInteger 5.  I ran it in an ArcCatalog python window and I got a message window right away saying "The calculated value is invalid for the row with ObjectID = 0. For example, the calculated value may be too large for the field or you may be trying to add a string to a number field.  ...."  However the Calculate Field tool ran successfully.   So is there a way to change the data type while calculating the field in arcpy, because I'd like to batch process a bunch of shapefiles like this.

This should be an easy one for someone out there.

Outcomes