CalculateField_management for a numeric field using value of string field with text

943
1
04-14-2011 11:28 AM
ChristopherJursa
New Contributor
Hello,

I am using ArcGIS 10 with python scripting.

I want to use CalculateField_management to calculate the values of a numeric field based on a string field.  However, the string field may have values that are not numeric.  Hence, I am getting an error prompt to continue processing if desired.  The prompt is in the attachment. 

I usually get this message when I am doing this in ArcMap and trying to set the numeric field to the string field where non-numeric text exists.  However, I am doing this in a python script and the prompt comes up each time.  Is there a way around this? 

My code is as follows.

arcpy.CalculateField_management(tablePath, 'numericFieldName', '[stringFieldName]', 'VB')

Again, is there any way to complete processing without clicking ok on this prompt?
Tags (2)
0 Kudos
1 Reply
TerrySilveus
Occasional Contributor III
you could try checking ord(field) first if it returns 48 through 57 it is a digit 0 through 9, you will probably have to check each character in the field, if you get anything outside this range, then skip that one and don't try to convert it to a number or read it as a number
0 Kudos