Select to view content in your preferred language

Batch Deleting Survey Data from Survey 123

401
3
03-22-2024 08:22 AM
TylerGingras
New Contributor

I am trying to seek some assistance in cleaning up our Survey 123 data from one survey form. We currently have over 3000 records that include field data, geolocations and photos. In an attempt to clean things up and free of up some space, I would like to delete most of the records (they have all been backed up onto a company server.) I realize that batch deleting on the Survey 123 website is not possible and you can only delete one record at a time. This is going to be very time consuming with 3000 records, so I am trying to figure out a way to batch delete the records based on date the record was created. I have read over the articles FAQ: Is It Possible to Batch Delete Features in ArcGIS Online? (esri.com) and How To: Batch Delete Features from an ArcGIS Online Hosted Feature Layer (esri.com) however I am still having difficulties understanding how to find the correct Object IDs to delete all of the records. 

Any help in this matter would be greatly appreciated.

Thanks,

Tyler

0 Kudos
3 Replies
BenBlowers2
New Contributor III

Hi @TylerGingras 

Do you have ArcGIS Pro? If so you could open the feature service through the Portal in ArcGIS Pro and delete the records from there using the attribute table to help.

Ben

MErikReedAugusta
Occasional Contributor III

I haven't done this, myself, but I would think you'd be able to use the Where clause on that page and enter a SQL query for the date range you wanted to delete.

Say you wanted to keep the surveys from today and delete anything older than that, and that your date field was just called "Date":

Date < '2024-03-22'

 

0 Kudos
JessicaRamirez1
New Contributor III

Hi, I used this script in a notebook. It saves the data to a geodatabase including all attachments and saves it in AGOL. Then it deletes the data in the survey. 

import arcgis.gis

gis = arcgis.GIS("home") #replace these with your credentials
item_id='xxxxxxxxxxxxxxxxxxxxx' #repace with the service_ID of the hosted feature layer to download
GDBname = "Temp_FGB1" # name of the temporary GDB to be saved in ArcGIS Online

AGOLitem = gis.content.get(item_id)
print ("Exporting Hosted Feature Layer...")
AGOLitem.export(GDBname,'File Geodatabase', parameters=None, wait='True')
time.sleep(10)#add 10 seconds delay to allow export to complete

arcpy.management.DeleteRows(
in_rows=r'https://services1.arcgis.com/yourdata/FeatureServer/0'
) #replace with your survey feature service
print ("Deleted Rows")

I hope that helps.

 

0 Kudos