I am attempting to automate a process of exporting photos from a Survey123 geodatabase and give the output a custom filename, modified from the general script for exporting photos provided by Esri. Here is what I have so far. I am trying to join the Feature Layer, image_repeat table and image_repeat__ATTACH table before exporting the photos so that I can use fields that are in the feature class attribute table in the output file names.
import arcpy
from arcpy import da
import os
featureTable = arcpy.GetParameterAsText(0)
repeatTable = arcpy.GetParameterAsText(1)
attachTable = arcpy.GetParameterAsText(2)
fileLocation = arcpy.GetParameterAsText(3)
arcpy.AddJoin_management(repeatTable, "parentglobalid", featureTable, "globalid")
arcpy.AddJoin_management(repeatTable, "Nutrient_Bank_Monitoring.globalid", attachTable, "REL_GLOBALID")
with da.SearchCursor(repeatTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID', 'site', 'plot']) as cursor:
for item in cursor:
attachment = item[0]
site = str(item[3])
plotNum = str(item[4])
filenum = "ATT" + str(item[2]) + "_"
filename = site + "_Plot" + plotNum + "_" + filenum + str(item[1])
open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
del item
del filenum
del filename
del attachment
However, I get the following error message - "The value cannot be a table":
I have no problem doing the joins manually in ArcMap, so I'm unclear why it won't work in the script. Is it possible to do what I'm trying to do?
I am obviously still a python newbie, so many thanks in advance for any help or advice!
Best,
Katie
“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek