Hi,
I`m using this script to export attachments from my geodatabase:
import arcpy
from arcpy import da
import os
inTable = arcpy.GetParameterAsText (0)
fileLocation = arcpy.GetParameterAsText (1)
with da.SearchCursor(inTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID']) as cursor:
for item in cursor:
attachment = item[0]
filenum = str(item [2]) + "_"
filename = str(item[1])
open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
del item
del filenum
del filename
del attachment
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?
Yes, i`m using ArcMap 10.4.1
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.
C:\Users\BBrzezinski\Desktop\Export.py - path of script;
D:\07_PRACE_GIS\Phyton_Toolbox\Toolbox.tbx - path of toolbox
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[2]: 'D:\x07_PRACE_GIS\\Phyton_Toolbox\\Toolbox.tbx'
p = r"D:\07_PRACE_GIS\Phyton_Toolbox\Toolbox.tbx"
p
Out[4]: 'D:\\07_PRACE_GIS\\Phyton_Toolbox\\Toolbox.tbx'