HOW TO
Generating individual reports in ArcGIS Survey123 is time-consuming if many reports are generated in a single survey form. This task can be automated using the ArcGIS API for Python arcgis.apps.survey123 module. Follow the workflow described in this article to generate and download the ArcGIS Survey123 reports using a stand-alone Python file (.py). The Python file also runs in Jupyter Notebook.
from arcgis.gis import GIS import os from zipfile import ZipFile from arcgis.apps.survey123._survey import SurveyManager, Survey
gis = GIS("https://www.arcgis.com","Username","Password") survey_mgr = SurveyManager(gis)
surveyForm = survey_mgr.get("Survey123_Form_ID")
print(surveyForm.report_templates)
templateChoice = surveyForm.report_templates[0] print(templateChoice)
save_path = r'Folder_Location'
output = letslearn.generate_report(report_template=choice, folder_id='ArcGIS_Online_Folder_ID', report_title="TestReport")
survey_list = gis.content.search(query='owner:<Owner_name> NOT tags:Print Template', item_type='Microsoft Word')
for x in survey_list: id=x.id data_item=gis.content.get(id) data_item.download(save_path) data_item.delete() #can be removed if the Report is necessary in ArcGIS Online as an item.
The code block below demonstrates the full script.
from arcgis.gis import GIS import os from zipfile import ZipFile from arcgis.apps.survey123._survey import SurveyManager, Survey gis = GIS("https://www.arcgis.com","User_1","Pass123@") survey_mgr = SurveyManager(gis) letslearn = survey_mgr.get("116aadjdj6kf7hjhv980wh") print(letslearn.report_templates) choice = letslearn.report_templates[0] print(choice) save_path = r'C:\Users\Username\Desktop\Survey' output = letslearn.generate_report(report_template=choice, folder_id='890002c6dsca542jassxceg', report_title="TestReport") survey_list = gis.content.search(query='owner:<Owner_Name> NOT tags:Print Template', item_type='Microsoft Word') for x in survey_list: id=x.id data_item=gis.content.get(id) data_item.download(save_path) data_item.delete()
Get help from ArcGIS experts
Download the Esri Support App