Skip to content

Instantly share code, notes, and snippets.

@oevans
Created June 10, 2013 20:18
Show Gist options
  • Save oevans/5751912 to your computer and use it in GitHub Desktop.
Save oevans/5751912 to your computer and use it in GitHub Desktop.
Step 5 - Add attachments
import arcpy, os, simplejson as json
cwd = os.getcwd()
### Load JSON File ###
with open('damageassessmentservice.json') as data_file:
data = json.load(data_file)
### Create Match Table ###
rows = arcpy.InsertCursor(cwd + '/data.gdb/MatchTable')
for cmtX in data['layers'][0]['attachments']:
row = rows.newRow()
row.setValue('GlobalID_Str', cmtX['parentGlobalId'])
row.setValue('PhotoPath', cwd + '\\photos\\' + cmtX['parentGlobalId'] + '\\' + cmtX['name'])
rows.insertRow(row)
del row
del rows
### Add Attachments ###
arcpy.AddAttachments_management(cwd + '/data.gdb/Damage_Assessment', 'GlobalID_Str', cwd + '/data.gdb/MatchTable', 'GlobalID_Str', 'PhotoPath')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment