Created
June 10, 2013 20:18
-
-
Save oevans/5751912 to your computer and use it in GitHub Desktop.
Step 5 - Add attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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