I'm stuck. I am trying to overwrite an existing csv file on a survey I published but it's not working. I have no errors. I run the script but the csv file doesn't change on the media folder on AGOL when I redownload the published form in survey123 connect. What am I doing wrong?
import arcgis
from arcgis.gis import GIS
import tempfile
import zipfile
import shutil
import os
# Script Parameteres
portalURL = r'https://egas.maps.arcgis.com/'
username = '***'
password = '***'
itemID = '***'
updated_files = ['Join_Features_to_Monitoring_Routes_v411_0.csv']
source_loc = r'C:/Users/jnmiller/Downloads/'
download_folder = r'C:/Users/jnmiller/Downloads/'
#----------------------------------------------------------
# Connect to GIS
gis = GIS(portalURL, username, password, verify_cert=False)
#------------------------------------------------
survey_manager = arcgis.apps.survey123.SurveyManager(gis)
surveyId = survey_manager.get(itemID)
surveyProp = surveyId.properties
print(surveyProp)
I would check out the newish linked content. You add a CSV to AGOL then link to that. I think that would be easier to update via script. I update manually but it has been way easier. I have 12 forms all linked to one central people list.
See
Hope that helps
Is that the full script? There's nothing in that script to actually update the csv, you're just getting the properties of the survey and printing them. My usual approach to updating csv choice lists is to publish the csv to AGOL and then reference that list as linked content in the survey as outlined in https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-external-choice/ba...
Once you've done that you can update that csv using something like this:
choice_list_itemID = [Item ID of the csv on AGOL]
choice_list_folder = [folder with the updated csv]
choice_list_name = [name of the updated csv]
choiceList = gis.content.get(choice_list_itemID)
choiceList_collection = FeatureLayerCollection.fromitem(choiceList) choiceList_collection.manager.overwrite(choice_list_folder + choice_list_name)