Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I was handed off a a bunch of state shape files 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).

share|improve this question
add comment

1 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.

share|improve this answer
    
I solved this issue by using \\ in the pathway instead of a single \. 'C:\\WB_prj\\cityPts\\ghosts.gdb\\vietnam_adm3_citypt_albers_ghost' –  user2284060 Jul 14 '13 at 20:04
    
Oops - the double slashes out in my second example did not show up due to formatting –  PolyGeo Jul 14 '13 at 20:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.