[GIS] Why does AddField give ERROR: 000732 Input Table: does not exist or is not supported

arcgis-10.0arcpyerror-000732

I was handed off a a bunch of state shapefiles and wrote a script to add a few new fields and calculate some attributes. The first line in my script is –

arcpy.AddField_management('C:\WB_prj\cityPts\ghosts.gdb\vietnam_adm3_citypt_albers_ghost', 'City_cnt', 'SHORT', '#', '#', '#', '#', 'NULLABLE', 'NON_REQUIRED', '#')

I have all of the state shapefiles in a geodatabase. The script runs perfect for some of the files but for others I get an error that is shown below. My pathways are correct and I can manually add the fields through ArcMap but when I try and run the script for some of them I get the error. Any ideas on how to solve this? I'm running ArcGIS 10.0

File "C:\WB_prj\scripts\ghostRegions_final.py", line 79, in
add_fields() File "C:\WB_prj\scripts\ghostRegions_final.py", line 14, in add_fields
arcpy.AddField_management('C:\WB_prj\cityPts\ghost.gdb\vietnam_adm3_citypt_albers_ghost',
'City_cnt', 'SHORT', '#', '#', '#', '#', 'NULLABLE', 'NON_REQUIRED',
'#') File "C:\Program Files
(x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 2625, in
AddField
raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Table: Dataset C:\WB_prj\cityPts\ghost.gdb
ietnam_adm3_citypt_albers_ghost does not exist or is not supported
Failed to execute (AddField).

Best Answer

Try:

r'C:\WB_prj\cityPts\ghosts.gdb\vietnam_adm3_citypt_albers_ghost'

or

'C:\\WB_prj\\cityPts\\ghosts.gdb\\vietnam_adm3_citypt_albers_ghost'

or

'C:/WB_prj/cityPts/ghosts.gdb/vietnam_adm3_citypt_albers_ghost'

Your syntax of 'C:\WB_prj\cityPts\ghosts.gdb\vietnam_adm3_citypt_albers_ghost' will use the single "\" as an escape character and thus not work.