Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. # encoding: utf-8
  2. import arcpy
  3. import _csv
  4. import os
  5. import sys
  6.  
  7. arcpy.env.workspace = "F:/全国省级、地市级、县市级行政区划shp/全国省级、地市级、县市级行政区划shp/New Personal Geodatabase.mdb"
  8. input = "F:/New Personal Geodatabase.mdb/Province"
  9. inputField = "OBJECTID"
  10. matchTable = r"F:matchtable.csv"
  11. matchField = "OBJECTID"
  12. pathField = "Picture"
  13. picFolder = r"F:MGS"
  14.  
  15. writer = _csv.writer(open(matchTable, "wb"), delimiter=",")
  16. writer.writerow([matchField, pathField])
  17.  
  18. for file in os.listdir(picFolder):
  19. if str(file).find(".jpg") > -1:
  20. writer.writerow([str(file).replace(".jpg", ""), file])
  21.  
  22. del writer
  23.  
  24. arcpy.EnableAttachments_management(input)
  25. arcpy.AddAttachments_management(input, inputField, matchTable, matchField, pathField, picFolder)
  26.  
  27. Traceback (most recent call last):
  28. File "F:/���ֿμ��͹�������/ʵϰ/ArcPy Sandbox/AutomateScript/BatchAddAttribute.py", line 29, in <module>
  29. arcpy.AddAttachments_management(input, inputField, matchTable, matchField, pathField, picFolder)
  30. File "F:ArcGIS 10.2.1Engine10.2arcpyarcpymanagement.py", line 124, in AddAttachments
  31. raise e
  32. arcgisscripting.ExecuteError: ERROR 000228: Cannot open the dataset.
  33. Failed to execute (AddAttachments).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement