arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear",'[NUM1] & "°" & [NUM2]',"VB") File "C:\Users\Administrator\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{7F12A0CE-D617-8330-5EBC-E045415D9345}\PlanTool_addin.py", line 105 SyntaxError: Non-ASCII character '\xb0'
Solved! Go to Solution.
exp = 'str(!NUM1!) + "\xb0" + str(!NUM2!)' >>> arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear", exp,"PYTHON 9.3") ... Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3128, in CalculateField raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of VB | PYTHON | PYTHON_9.3. Failed to execute (CalculateField).
Thanks, but this is what I got:exp = 'str(!NUM1!) + "\xb0" + str(!NUM2!)' >>> arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear", exp,"PYTHON 9.3") ... Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 3128, in CalculateField raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of VB | PYTHON | PYTHON_9.3. Failed to execute (CalculateField).
exp = 'str(!NUM1!) + "\xb0" + str(!NUM2!)' arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear", exp,"PYTHON_9.3")
Well this one you should be figuring out, since it tells you in the error what the problem is this time. You missed the underscore in "PYTHON_9.3" (You wrote "PYTHON 9.3")exp = 'str(!NUM1!) + "\xb0" + str(!NUM2!)' arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear", exp,"PYTHON_9.3")
If you want a space between the numbers and the minutes symbol after the second number, the expression should be:
exp = 'str(!NUM1!) + "\xb0 " + str(!NUM2!) + "'"'
>>> exp = 'str(!NUM1!) + "\xb0 " + str(!NUM2!) + "'"' Parsing error SyntaxError: EOL while scanning string literal (line 1)
Well this one you should be figuring out, since it tells you in the error what the problem is this time. You missed the underscore in "PYTHON_9.3" (You wrote "PYTHON 9.3")exp = 'str(!NUM1!) + "\xb0" + str(!NUM2!)' arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear", exp,"PYTHON_9.3")
If you want a space between the numbers and the minutes symbol after the second number, the expression should be:
exp = 'str(!NUM1!) + "\xb0 " + str(!NUM2!) + "'"'
# Process: Calculate Field arcpy.CalculateField_management("GISMainFabric_Line_Clip_0", "Bear", "str( !NUM1! ) + \"\\xb0 \" + str( !NUM2! ) + \"'\"", "PYTHON_9.3", "")
If I had done this in Model Builder and exported it to Python like I normally do this thread would not be up to 16 posts. That is how I do it normally.
Here is from the Model Builder export of a calculation that worked.# Process: Calculate Field arcpy.CalculateField_management("GISMainFabric_Line_Clip_0", "Bear", "str( !NUM1! ) + \"\\xb0 \" + str( !NUM2! ) + \"'\"", "PYTHON_9.3", "")
If I had done this in Model Builder and exported it to Python like I normally do this thread would not be up to 16 posts. That is how I do it normally.
Here is from the Model Builder export of a calculation that worked.# Process: Calculate Field arcpy.CalculateField_management("GISMainFabric_Line_Clip_0", "Bear", "str( !NUM1! ) + \"\\xb0 \" + str( !NUM2! ) + \"'\"", "PYTHON_9.3", "")
exp = 'str(!NUM1!) + "\xb0 " + str(!NUM2!) + "\'"'
Harder to read though. I think you had it before, just needed to escape the ':exp = 'str(!NUM1!) + "\xb0 " + str(!NUM2!) + "\'"'
The whole deal is kind of confusing because you have to write code that has to evaluate to a string that has to evaluate to code.