I have this table:
And I want to create a field called "COSN2" which after the creation I want to fill it with three characters from the field "COS207". Than I wrote the following script:
import arcpy, os
from arcpy import env, UpdateCursor
from arcpy.management import AddField
arcpy.env.overwriteOutput=True
arcpy.env.workspace="C:\Users\Thomas\Desktop\Trabalho AE\Trabalho.gdb"
fc="COS2007"
arcpy.AddField_management(fc,"COSN2","TEXT","","","","NULLABLE")
arcpy.CalculateField_management(fc,"COSN2","LEFT([CONS2007],3)","VB")
cursor=arcpy.SearchCursor(fc)
for row in cursor:
print row.COS2007+" ; "+row.COSN2
Then the eclipse returns me an error:
Traceback (most recent call last):
File "F:\MSIGOT\AE\AnaliseEsp\TrabalhoAE\COSN2.py", line 10, in <module>
arcpy.CalculateField_management(fc,"COSN2","LEFT([CONS2007],3)","VB")
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py", line 3360, in CalculateField
raise e
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Failed to execute (CalculateField).
I've tried to change "VB" (above) to "PYTHON" and "PYTHON_9.3" but the error persists.
Can anyone explain this?