Select to view content in your preferred language

Export a SUBSET of Survey123 Photo Attachments

320
4
09-10-2024 08:56 AM
PinPointTrim
New Contributor

Posting this to see if anyone have any ideas as I am still a beginner with Python. The export survey data script Export survey data with attachments | ArcGIS Survey123 exports all of the attachments but within my Survey123 I'd like to just export a subset (in this case date ranges, my column name is SurveyDate) I tried to modify the query line but it seems like I am supposed to define "SurveyDate" parameter somewhere in the code. Not sure what I am doing wrong. Any ideas would be helpful Thanks.

0 Kudos
4 Replies
MErikReedAugusta
Frequent Contributor

Make sure your query is still in quotes.  If the script is talking about a parameter named SurveyDate, my first assumption would be that you deleted the quotes.

Consider (fairly certain this is correct):

 

feature_object_ids = i.query(where="SurveyDate > '2024-09-10T12:12:00.000'", ...

 

vs (Incorrect):

 

feature_object_ids = i.query(where=SurveyDate > '2024-09-10T12:12:00.000' ...

 

DISCLAIMER 1: Dates generally refuse to stick in my brain when it comes to SQL, so the actual query above might be an issue.  But placing the whole thing in quotes like that shouldn't be.

DISCLAIMER 2: There's also the fun mayhem of whether or not your field name also needs quotes or other delimiters around it; I can never keep straight which database types do and don't.  I also have no idea which pattern Survey123 follows, either.  I say try without any delimiters around the field name (but make sure that it is in a string!)

0 Kudos
MErikReedAugusta
Frequent Contributor

The important takeaways here that can burn you if you're not careful:

  1. Generally, ArcGIS stores SQL queries as strings.  Make sure the whole query is surrounded by quotes of some kind.  Also make sure those outer quotes don't conflict with #2 or #3 below.  Double quotes are usually safe.  In a rare case where it isn't, I typically (mis-?)use a docstring.  Put three pairs of double-quotes around your query, instead of the usual single pair.
  2. Sometimes the field name might need delimiters like quotes or brackets, depending on your database.
  3. Generally, string components in SQL queries need single quotes.
0 Kudos
PinPointTrim
New Contributor

Thanks @MErikReedAugusta When I tried to modify the query as you suggested, I get 'Invalid Field: SurveyDate' parameter is invalid (Error code: 400). I am guessing this parameter needs to be defined somewhere in the code, I could be wrong

0 Kudos
MErikReedAugusta
Frequent Contributor

Can you try posting a copy of your modified code here?

0 Kudos