Esri / Survey123-tools

Tools for ArcGIS Survey123
Apache License 2.0
42 stars 20 forks source link

Code to access related tables generated by a Survey123 repeat #8

Closed ka78 closed 11 months ago

ka78 commented 2 years ago

@Zachary-Sutherby I'm attempting to use a combo of the "Work with survey data" and "Export survey data" to access, filter, join (using pandas merge) child records to parent records and then export data from Survey123.

My survey has a repeat. I'm unclear how to get at the related records from repeat.

When I view the pandas df tail in JN, I see only the records from the "parent" portion of the form. Can you help me understand how I can get the related records as well? Thanks.

Zachary-Sutherby commented 2 years ago

Hello @ka78 the .download() method available in the Survey123 module is always going to return the [0] index layer in the dataframe. To work with a related table in a dataframe I would suggest doing something like the following to work with a related table:

from arcgis.features import FeatureLayer import pandas as pd fl =FeatureLayer(('Related table REST endpoint')) pd.DataFrame.spatial.from_layer(fl)