DOC
|
@Felicitychun Thank you for your response! It seems that your suggestion resolved that error. Now when I run the script, it seems to feed me back the code, and the file path I tried to feed the attachments in was empty. I really appreciate any response! A newbie to python and trying to improve! @MichaelKelly
... View more
12-09-2020
07:33 AM
|
0
|
0
|
852
|
DOC
|
Hi, So I got the Jupyter Notebook open, I saved the attachment, and went in to customize the code to my needs. Ran the code and got this error: NameError Traceback (most recent call last) <ipython-input-2-17b343b15353> in <module> 9 "start_time": "2017-08-16T09:06:05.091046Z" 10 }, ---> 11 "scrolled": false 12 }, 13 "outputs": [ NameError: name 'false' is not defined I'm trying to figure this out in the mean time, but please let me know if you can help me. @MichaelKelly
... View more
12-07-2020
01:40 PM
|
0
|
0
|
878
|
POST
|
rvburton Please let me know if you have any clue, or might need more information to potentially help, if you could!
... View more
08-13-2020
10:59 AM
|
0
|
1
|
163
|
POST
|
So I've been following these instructions. This is my code: ---------------------------------------------------------------------------------------------------------- import arcpy masterFC = r"C:\Users\kameehan\OneDrive - Westwood Active Directory\Documents\Project_Documents\UI_Railroad\Shapefiles\Observations_FGDB\UI_Walkdown_Observations.gdb\Observations" masterFlds = ['GlobalID', 'NAME'] # Use list comprehension to build a dictionary from a da SearchCursor masterDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(masterFC, masterFlds)} print(masterDict) relatedTbl = r'C:\Users\kameehan\OneDrive - Westwood Active Directory\Documents\Project_Documents\UI_Railroad\Shapefiles\Observations_FGDB\UI_Walkdown_Observations.gdb\Observations_ATTACH' relatedFlds = ['REL_GLOBALID', 'ATT_NAME', 'DATA'] fileLocation = r'C:\Users\kameehan\OneDrive - Westwood Active Directory\Documents\Project_Documents\UI_Railroad\Shapefiles\Observations_FGDB\UI_Walkdown_Observations.gdb\Observations_ATTACH' with arcpy.da.SearchCursor(relatedTbl, relatedFlds) as cursor: for item in cursor: # item[0] is related GlobalID; take first item in masterDict tuple with that key f1 = masterDict[item[0]][0].replace(" ","_") # replacing spaces # assuming attachment name starts with "attachment", remove that part and keep rest f2 = item[1][10:] # can use .split('.')[1:] or similar to get just extension # make new filename filename = "ATT_{}_{}".format(f1, f2) print (filename) open(fileLocation + os.sep + filename, 'wb').write(item[2].tobytes()) del cursor --------------------------------------------------------------------------------------------------------------------------- and I keep getting this error: Traceback (most recent call last): File "C:\Users\kameehan\OneDrive - Westwood Active Directory\Documents\ExportAttachments2.py", line 16, in <module> with arcpy.da.SearchCursor(relatedTbl, relatedFlds) as cursor: RuntimeError: cannot open 'C:\Users\kameehan\OneDrive - Westwood Active Directory\Documents\Project_Documents\UI_Railroad\Shapefiles\Observations_FGDB\UI_Walkdown_Observations.gdb\Observations_ATTACH' Failed to execute (ExportAttachments2). And I'm not sure how to fix it or what is wrong. As in why won't it open that file path?
... View more
08-13-2020
10:41 AM
|
0
|
2
|
163
|
POST
|
When exporting batch attachments from an ArcGIS Online layer, I use the code from this GeoNet suggestion: https://support.esri.com/en/technical-article/000017450 . From here, I want to change the code to create individual folders for each point's attachments. Can anyone help me do this? I'm not knowledgeable of ArcPy, but here is the code in the tool created: 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 = "ATT" + str(item[2]) + "_" filename = filenum + str(item[1]) open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes()) del item del filenum del filename del attachment
... View more
08-05-2020
12:23 PM
|
0
|
0
|
103
|
Online Status |
Offline
|
Date Last Visited |
12-21-2020
12:57 PM
|