<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Feature report download for multiple records in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812642#M13729</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it is.&amp;nbsp; I am using a script originally posted by&amp;nbsp;John Stowell in 2019, which I have amended to loop through a set of queries and output to different local folders.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The relevant part of the code is below. As I said, it works fine of there is one record returned by the "where_filter".&amp;nbsp; If more than one is returned, the reports are generated into a zip file, but not downloaded.&amp;nbsp; Having just pasted the code below, I am wondering whether it is because the zip file is not found by survey.reports?&amp;nbsp; However, until recently the whole thing was working, and was downloading doc files regardless of how many there were.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;interval = today-datetime.timedelta(seconds = 3600)
reportCount = 0
     # Try/except/finally block to workaround the KeyError: 'results' bug in the generate_report method
     # SJG: Think this bug has been fixed, but have left try/except in just in case
     try:
        print('Generating report(s) for submissions from last hour', file=open(log, "a"))
        print('')
        survey.generate_report(template, where_filter, utc_offset, report_title) 
     except Exception as e:
        print('&amp;gt;&amp;gt; ERROR: KeyError: ',e,' (related to ESRI BUG-000119057)', file=open(log, "a"))
        print('&amp;gt;&amp;gt; Continuing...', file=open(log, "a"))
        print('')
        pass
     finally:
        print('Downloading relevant report(s) to: ',output_folder, file=open(log, "a"))
        print('')
        for x in survey.reports: 
           # Find the creation date (Unix epoch) and convert to local time
           creationdate = datetime.datetime.fromtimestamp(x.created / 1e3)

           # Only find and download AGOL reports created in the last half hour (specified in "interval" variable)
           if (creationdate &amp;gt; interval): 
              reportCount += 1
              id = x.id # Get ID of each Word doc AGOL item
              print('Report number: ', reportCount, file=open(log, "a"))
              data_item = agol_login.content.get(id) 
              data_item.download(save_path = output_folder) # Download each Word doc to specified location
              time.sleep(15)
              data_item.delete() # Delete the item in AGOL folder after download
        # Finally block end&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:33:58 GMT</pubDate>
    <dc:creator>SimonGee</dc:creator>
    <dc:date>2021-12-12T09:33:58Z</dc:date>
    <item>
      <title>Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812640#M13727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Python script that checks a survey every hour, exports feature reports for any features added in the hour and downloads them to a local folder.&amp;nbsp; It was working fine until last week, regardless of how many records there were, often downloading multiple .docx files each time it ran.&amp;nbsp; Now it works as expected for single surveys, but if there is more than one survey matching the filter query it produces a zip file on the website (you can see it in recent activity, and manually download it) but doesn't download the file to the local folder.&amp;nbsp; I know that this is how it works if you export multiple reports directly on the S123 website, but the scripted download was previously returning individual files.&amp;nbsp; Has something changed on the back end that has caused this behaviour, and is it expected?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 15:26:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812640#M13727</guid>
      <dc:creator>SimonGee</dc:creator>
      <dc:date>2020-07-20T15:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812641#M13728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Simon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to check, this is being done with the ArcGIS API for Python? &amp;nbsp;Can you provide a snippet of the code you're using to generate &amp;amp; download?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 16:23:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812641#M13728</guid>
      <dc:creator>JamesTedrick</dc:creator>
      <dc:date>2020-07-20T16:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812642#M13729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it is.&amp;nbsp; I am using a script originally posted by&amp;nbsp;John Stowell in 2019, which I have amended to loop through a set of queries and output to different local folders.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The relevant part of the code is below. As I said, it works fine of there is one record returned by the "where_filter".&amp;nbsp; If more than one is returned, the reports are generated into a zip file, but not downloaded.&amp;nbsp; Having just pasted the code below, I am wondering whether it is because the zip file is not found by survey.reports?&amp;nbsp; However, until recently the whole thing was working, and was downloading doc files regardless of how many there were.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;interval = today-datetime.timedelta(seconds = 3600)
reportCount = 0
     # Try/except/finally block to workaround the KeyError: 'results' bug in the generate_report method
     # SJG: Think this bug has been fixed, but have left try/except in just in case
     try:
        print('Generating report(s) for submissions from last hour', file=open(log, "a"))
        print('')
        survey.generate_report(template, where_filter, utc_offset, report_title) 
     except Exception as e:
        print('&amp;gt;&amp;gt; ERROR: KeyError: ',e,' (related to ESRI BUG-000119057)', file=open(log, "a"))
        print('&amp;gt;&amp;gt; Continuing...', file=open(log, "a"))
        print('')
        pass
     finally:
        print('Downloading relevant report(s) to: ',output_folder, file=open(log, "a"))
        print('')
        for x in survey.reports: 
           # Find the creation date (Unix epoch) and convert to local time
           creationdate = datetime.datetime.fromtimestamp(x.created / 1e3)

           # Only find and download AGOL reports created in the last half hour (specified in "interval" variable)
           if (creationdate &amp;gt; interval): 
              reportCount += 1
              id = x.id # Get ID of each Word doc AGOL item
              print('Report number: ', reportCount, file=open(log, "a"))
              data_item = agol_login.content.get(id) 
              data_item.download(save_path = output_folder) # Download each Word doc to specified location
              time.sleep(15)
              data_item.delete() # Delete the item in AGOL folder after download
        # Finally block end&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812642#M13729</guid>
      <dc:creator>SimonGee</dc:creator>
      <dc:date>2021-12-12T09:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812643#M13730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just bumping this. Still having the same problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2020 14:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812643#M13730</guid>
      <dc:creator>SimonGee</dc:creator>
      <dc:date>2020-08-17T14:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812644#M13731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm experiencing the same issue.&amp;nbsp; I'm using &lt;SPAN style="background-color: #ffffff;"&gt;ArcGIS API for Python with&amp;nbsp;&lt;/SPAN&gt;code similar to what Simon posted &amp;nbsp;(I modified the code posted by John Stowell).&amp;nbsp;&amp;nbsp;It works great with the exception of the Zip file when there are multiple reports run.&amp;nbsp; I would like it to continue to place individual word docx files in my AGOL folder and not create the zip file. After the download of the docx file I have a secondary script that renames the docx file and saves it as a PDF.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2020 18:37:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812644#M13731</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-09-19T18:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Feature report download for multiple records</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812645#M13732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems that this issue could be solved at least for some use cases if the survey123 module for python could accommodate the selection to 'Merge' multiple reports in a single file. In other words, in the&amp;nbsp;survey.generate_report parameters one would be able to specify merge. I don't suppose it could be easily 'hacked' in _survey.py, but if so, it would help some folks to know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Oct 2020 16:28:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/feature-report-download-for-multiple-records/m-p/812645#M13732</guid>
      <dc:creator>JamesFaron</dc:creator>
      <dc:date>2020-10-12T16:28:40Z</dc:date>
    </item>
  </channel>
</rss>

