"Select by Attributes" query script

2702
5
Jump to solution
10-11-2014 08:31 AM
ArielCarballo
New Contributor

Hi,

 

I need to write a script that would extract the contents of a text file (see below)

 

123456

234567

890123

567890

 

and would write a script that later could be loaded when using "Select by Attributes" tool (see below).

 

query.jpg

 

P.S. I have a list of hundreds of numbers that I do not want to enter them one by one.

Your help would be greatly appreciated.

Thanks

0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Frequent Contributor II

Ariel,

if you have your list in a text document you could load it in to excel so each value is in separate rows down one column.

then create a formula to create your expression, e.g:

= "FID = '" & A1 & "'"

where A1 is the first cell that contains a value. Copy the formula down so that each row gets populated. If you the copy the values into notepad then copy and paste them into word ( this stops the column being added as a table in word). You can then do a find and replace to add the 'or' segments into your expression. ^p in word is hard return replace this with space OR space. This should give you your full expression that you can then paste into arcmap.

hope this helps

anthony

View solution in original post

0 Kudos
5 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Rather than select what you do want, it is sometimes quicker to select what you don't want then switch the selection. So to answer this question...if there a range of values that could be used rather than selecting them one at a time.  Would a spatial selection work better than an attribute selection... etc etc etc

0 Kudos
ArielCarballo
New Contributor

I have like 85000 items of which I only need to select around 450.

--

Sent from myMail app for Android

Saturday, 11 October 2014, 02:02PM -0400 from Dan Patterson <geonet@esri.com>:

GeoNet

"Select by Attributes" query script

reply from  Dan Patterson in  Ariel Carballo -  View the full discussion

0 Kudos
AnthonyGiles
Frequent Contributor II

Ariel,

if you have your list in a text document you could load it in to excel so each value is in separate rows down one column.

then create a formula to create your expression, e.g:

= "FID = '" & A1 & "'"

where A1 is the first cell that contains a value. Copy the formula down so that each row gets populated. If you the copy the values into notepad then copy and paste them into word ( this stops the column being added as a table in word). You can then do a find and replace to add the 'or' segments into your expression. ^p in word is hard return replace this with space OR space. This should give you your full expression that you can then paste into arcmap.

hope this helps

anthony

0 Kudos
ArielCarballo
New Contributor

Anthony,

Thanks for your prompt response, I'll try it.

--

Sent from myMail app for Android

Saturday, 11 October 2014, 02:04PM -0400 from Anthony Giles <geonet@esri.com>:

GeoNet

"Select by Attributes" query script

reply from  Anthony Giles in  Ariel Carballo -  View the full discussion

0 Kudos
ArielCarballo
New Contributor

It worked perfectly!! Thanks a lot!!

--

Sent from myMail app for Android

Saturday, 11 October 2014, 02:04PM -0400 from Anthony Giles <geonet@esri.com>:

GeoNet

"Select by Attributes" query script

reply from  Anthony Giles in  Ariel Carballo -  View the full discussion

0 Kudos