AnsweredAssumed Answered

Query and deleting feature in a AGOL layer

Question asked by gthistle_RMOW on Feb 26, 2019
Latest reply on Feb 26, 2019 by simo

I am trying to query and export features to a CSV file from an AGOl layer, and then have these features deleted from the layer aftwerwards: My code goes as follows:

 

import arcgis
from arcgis.gis import GIS
gis = GIS("https://arcgis.com", "User", "Password")
from arcgis.gis import *
import os
icy_conditions = gis.content.get('a6be839d462d4441802abad0728cc857')
icy_layers = icy_conditions.layers
icy_reports = icy_layers[0]
Status_query = icy_reports.query(where="Status='Cleared'")
output_file = icy_conditions.export(title=icy_reports,export_format="CSV",parameters=Status_query)
output_file.download(r'\\vm-gis-catalog\Web_GIS\AGOL\IceReporting\Archived_Reports')
if icy_reports.query(Status_query):
icy_reports.delete_features()

 

The script will run and export the features, but it does not select the records I want, it just exports all records in the layer. Can anyone help with regards to the export function and how you can incorporate querying a layer into this function?

 

Thanks!

Outcomes