Select by attribute using sequential values from spreadsheet

557
5
03-25-2020 06:01 PM
ColinO_Keefe
New Contributor II

I have a .csv of 40 values to iterate through to supply an input to the Select by Attribute tool.  The Select by Attribute tool will then use each of these values to pull these values separately from a single master dataset  and export as a separate feature for each .csv value to begin a number of operations in ModelBuilder.  How do I get the Select by Attribute tool to access the .csv one value at a time?

0 Kudos
5 Replies
JoshuaBixby
MVP Esteemed Contributor

It looks like you are using Model Builder.  Have you read over Examples of using iterators in ModelBuilder—Tools | Documentation ?

0 Kudos
ColinO_Keefe
New Contributor II

Hello Joshua,

Thanks for getting back to me.

I have been through the documentation, but am unable to make the link between the iterator and select by attribute.  I have use the labelled output of Iterate Field values as the inline variable for the selecting element of the Select by Attribute target input row.

Both the CSV and target field of the input table are text.  The input CSV has no header.   The error is ‘incorrect SQL expression’.

 

Regards,

Colin

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If the CSV header is the issue, can't you just add a header manually?

Similar to if you are writing Python, providing your model (or part of your model) will help people provide specific feedback.

0 Kudos
ColinO_Keefe
New Contributor II

I assumed removing the CSV header (attribute field label) would make it easier for the iterator to read the values.  These values are ecological communities effected by fires, represented by a number that aligns with an SDE master file.

The Select by Attribute draws on an SDE master file, from which I need to extract these particular values individually for further processing, using the expression : 

COM_ID = %IteratedSparkValue%

0 Kudos
DuncanHornby
MVP Notable Contributor

Using the iterator may be overkill if the values you want to extract out are already in the dataset, consider using just ONE tool called Split By Attributes. No need for a model/code/manual repetition. The only reason you may want to go down the road you are using is if the CSV contains a sub-set of the data you want to copy out from your master dataset?

0 Kudos