Hello !
I am a bit new to python in Arcgis, and I would need help.
I would like to update a csv automatically, based on a feature layer data. I am doing this currently by exporting the feature layer data manually, running a script that reads it, remove duplicates and writes a csv file in my folder and then I upload the file in Arcgis to update my arcgis online csv file.
I would like this to be done in Arcgis Online automatically without having to run the treatment on my computer. I have the feeling the notebook functionality could help but I have no idea what would be an appropriate script.
Can you help ? Thank you in advance 🙂
This tutorial shows how to get a hosted feature service by searching for a name and by using it's ID value. It also shows writing a file to the notebook workspace storage.
https://www.arcgis.com/home/item.html?id=50e536565b474898849dcae596c62202
This one shows using the Spatially Enabled Dataframe (a spatially extended version of a Pandas dataframe):
https://www.arcgis.com/home/item.html?id=30f62af60c9b4493bc3fa59d77209b2d
The pandas to CSV functions there, so you can use that syntax.
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html
Once you have a CSV in the Notebook storage space, you can keep it there, or if you need to be able to access it, you can publish it/overwrite one in ArcGIS Online.
See also:
https://developers.arcgis.com/python/guide/part3-data-io-writing-data/
and
https://developers.arcgis.com/python/samples/publishing-sd-shapefiles-and-csv/
Thank you so much for your replay. I think I am almost there. I extracted data from survey123 in csv format.
Now, i would like to directly write the item ct_data in Arcgis, without having to write it on my local computer first : is it possible ?
An addition : I realized that running this script actually, generated the corresponding csv file on Arcgis Online. However, everytime I re-run this, it doesn't overwrite the csv file : it writes a new one. How can I make sure each time I run this script, the csv file is overwritten ? Also, is there a way I can write this csv file in a specific folder in Arcgis ? Thank you so much