I`m using this script to export attachments from my geodatabase:
from arcpy import da
inTable = arcpy.GetParameterAsText (0)
fileLocation = arcpy.GetParameterAsText (1)
with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor:
for item in cursor:
attachment = item
filenum = str(item ) + "_"
filename = str(item)
open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
During procedure i get this warning:
Do you have idea what is wrong? Thanks for help.
yes... your folder D:\07_....
Copy and paste as text the actual folder name.
Always use raw encoding especially if you have a different internationalization. ie r"D:\MyStuff"
This line at the very top of your scripts goes a long way to fixing some issues
# -*- coding: UTF-8 -*-
I assume python 2.7? and ArcMap?
So what is the path??? it is not being interpreted properly and that suggests an issue with the characters in the folder path, which may be internationalization issues or the path strings are being interpreted wrong.
you need raw formatting... and beginning a path with a space is not good practice for obvious reasons
p = "D:\07_PRACE_GIS\Phyton_Toolbox\Toolbox.tbx" p Out: 'D:\x07_PRACE_GIS\\Phyton_Toolbox\\Toolbox.tbx' p = r"D:\07_PRACE_GIS\Phyton_Toolbox\Toolbox.tbx" p Out: 'D:\\07_PRACE_GIS\\Phyton_Toolbox\\Toolbox.tbx'