<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Query to have only numeric values in the field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558905#M43701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok... so do you know how to &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;list featureclasses&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm"&gt;ListFeatureClasses—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;get a featureclass from the list&lt;/LI&gt;&lt;LI&gt;get a list of fields , &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfields.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfields.htm"&gt;ListFields—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;then get a field from that list?&lt;/LI&gt;&lt;LI&gt;Then... cycle through the records that don't have a number in them?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;A little much and you are already jumping to batches.&lt;/P&gt;&lt;P&gt;What I might suggest for the interim for checking is the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;add a field to the feature classes table, called test, make it an integer field&lt;/LI&gt;&lt;LI&gt;using the field calculator, calculate values for that new field using the following idea&lt;/LI&gt;&lt;LI&gt;use the python parser, and calculate&amp;nbsp;&amp;nbsp;&amp;nbsp; int( !YourFieldWithClasses!.isdigit())&lt;/LI&gt;&lt;LI&gt;this will produce a field of 0 or 1 as in the example below&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "123456bb345"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; int(a.isdigit())&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "123456"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; int(a.isdigit())&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;Now if you just manually query the field for 1, then they are all the good fields and you can export them to a new feature class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you like that, it will save a bunch of stuff that you probably don't want to do now if you are learning.&amp;nbsp; If it works and it seems easy, then the next stage is coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 May 2016 20:11:04 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-05-17T20:11:04Z</dc:date>
    <item>
      <title>Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558901#M43697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feature class and one of its fields is Route type. I need to exclude from this Feature class all Routes that have any letter in the value (my values are 1203,1234,123B, BB and etc) I should have only numeric ones.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do it in my Python code?&lt;/P&gt;&lt;P&gt;Thank you in advance!!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 13:38:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558901#M43697</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-17T13:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558902#M43698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are options but this will get you thinking.&amp;nbsp; The results return a string which you can convert to an integer.&lt;/P&gt;&lt;P&gt;Since you have not indicated that you want decimals returned, this example is for integers.&amp;nbsp; Now to test for all are numbers, you don't parse the string you just check to see if they are all numbers as in the second example&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: Consolas;"&gt;&amp;gt;&amp;gt;&amp;gt; a&amp;nbsp;&amp;nbsp; # parse a string returning only the numbers
'123456AB78C'&lt;/SPAN&gt;
b = "".join([i for i in a if i.isdigit()])
&amp;gt;&amp;gt;&amp;gt; b
'12345678'
&amp;gt;&amp;gt;&amp;gt;
&lt;SPAN style="font-family: Consolas;"&gt;&amp;gt;&amp;gt;&amp;gt; a&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; check to see if all are numbers
'123456AB78C'
&amp;gt;&amp;gt;&amp;gt; b = a.isdigit()
&amp;gt;&amp;gt;&amp;gt; b
False
&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558902#M43698</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558903#M43699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the data source is a file geodatabase you can use Select By Attribute with an SQL expression like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAST(ROUTE_TYPE AS FLOAT) &amp;gt; -10000000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately this does not work with shapefiles, and I could not find help showing a similar method for that data source.&amp;nbsp; But I highly recommend that everyone convert their shapefiles to a file geodatabase for its superior performance and many other enhancements.&amp;nbsp; SDE data source types may have alternative methods of casting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 14:25:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558903#M43699</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-05-17T14:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558904#M43700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;I am new to Python, so I am bit confused what exactly I need to put in python. How I specify which feature class I want to edit and which field? I do not need decimals, just integers&lt;/P&gt;&lt;P&gt;This code will be a part of a batch job so there will be other feature classes as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 19:32:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558904#M43700</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-17T19:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558905#M43701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok... so do you know how to &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;list featureclasses&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfeatureclasses.htm"&gt;ListFeatureClasses—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;get a featureclass from the list&lt;/LI&gt;&lt;LI&gt;get a list of fields , &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfields.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfields.htm"&gt;ListFields—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;then get a field from that list?&lt;/LI&gt;&lt;LI&gt;Then... cycle through the records that don't have a number in them?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;A little much and you are already jumping to batches.&lt;/P&gt;&lt;P&gt;What I might suggest for the interim for checking is the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;add a field to the feature classes table, called test, make it an integer field&lt;/LI&gt;&lt;LI&gt;using the field calculator, calculate values for that new field using the following idea&lt;/LI&gt;&lt;LI&gt;use the python parser, and calculate&amp;nbsp;&amp;nbsp;&amp;nbsp; int( !YourFieldWithClasses!.isdigit())&lt;/LI&gt;&lt;LI&gt;this will produce a field of 0 or 1 as in the example below&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "123456bb345"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; int(a.isdigit())&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "123456"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; int(a.isdigit())&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;Now if you just manually query the field for 1, then they are all the good fields and you can export them to a new feature class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you like that, it will save a bunch of stuff that you probably don't want to do now if you are learning.&amp;nbsp; If it works and it seems easy, then the next stage is coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:11:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558905#M43701</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-17T20:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558906#M43702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I do it simpler using Field Calculator and writing small code there?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558906#M43702</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-17T20:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Query to have only numeric values in the field</title>
      <link>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558907#M43703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the part where I said add the field and ...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;use the python parser, and calculate&amp;nbsp;&amp;nbsp;&amp;nbsp; int( !YourFieldWithClasses!.isdigit())&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;yes&lt;/P&gt;&lt;P&gt;Not the part about cycling through featureclasses, adding the field and doing the calculation manually... that is the scripting part&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is why I said try it manually and if you like it then do some reading and it can be scripted...with help probably&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 22:07:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-to-have-only-numeric-values-in-the-field/m-p/558907#M43703</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-17T22:07:00Z</dc:date>
    </item>
  </channel>
</rss>

