<?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: Need to extract numbers from a field in attribute table in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526014#M87340</link>
    <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/774670"&gt;@EGardner7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you attach a picture of the error? It may be because something is null or does not show up correctly.&lt;/P&gt;&lt;P&gt;You could also try placing a function in the code block and calling it for your attribute selection:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def extract_numbers(field):
    numbers = ''.join([i for i in field if i.isdigit()])
    return int(numbers) if numbers else None

extract_numbers(!YourFieldName!)&lt;/LI-CODE&gt;&lt;P&gt;This would return None if numbers is not present.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2024 18:13:36 GMT</pubDate>
    <dc:creator>CodyPatterson</dc:creator>
    <dc:date>2024-08-22T18:13:36Z</dc:date>
    <item>
      <title>Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526007#M87338</link>
      <description>&lt;P&gt;I have two fields that contain addresses that I am trying to compare by making sure just the numbers match because the addresses in one of those fields are not standardized. I already have one field that contains the numbers for the addresses that are standardized so now I am trying to create a field for numbers for the non-standardized addresses. I need to extract the numbers from the other field so I can find the ones that do not match. I am trying to use this script:&lt;/P&gt;&lt;P&gt;int(''.join([i for i in !YourFieldName! if i.isdigit()]))&lt;/P&gt;&lt;P&gt;But I get an error processing popup. I am new to using python so I was hoping someone might be able to point me in the right direction. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:14:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526007#M87338</guid>
      <dc:creator>EGardner7</dc:creator>
      <dc:date>2024-08-22T18:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526014#M87340</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/774670"&gt;@EGardner7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you attach a picture of the error? It may be because something is null or does not show up correctly.&lt;/P&gt;&lt;P&gt;You could also try placing a function in the code block and calling it for your attribute selection:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def extract_numbers(field):
    numbers = ''.join([i for i in field if i.isdigit()])
    return int(numbers) if numbers else None

extract_numbers(!YourFieldName!)&lt;/LI-CODE&gt;&lt;P&gt;This would return None if numbers is not present.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:13:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526014#M87340</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-22T18:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526024#M87344</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="T Gateway error.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/113275iDBCFE47A7CBED01E/image-size/large?v=v2&amp;amp;px=999" role="button" title="T Gateway error.png" alt="T Gateway error.png" /&gt;&lt;/span&gt;Hi Cody thanks for your response. Here is the error message.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:21:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526024#M87344</guid>
      <dc:creator>EGardner7</dc:creator>
      <dc:date>2024-08-22T18:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526033#M87346</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/774670"&gt;@EGardner7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It may be how you are returning the function, I believe you are trying to return an integer, is the AncillaryRole field an integer field? If it is not, you may try changing the datatype to be a string or similar using the string function str(), you may not even need to use str() as it could be returning as a string already:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def extract_numbers(field):
    numbers = ''.join([i for i in field if i.isdigit()])
    return str(numbers) if numbers else None

extract_numbers(!YourFieldName!)&lt;/LI-CODE&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526033#M87346</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-22T18:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526105#M87355</link>
      <description>&lt;P&gt;Hey Cody I got a different error message this time.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-08-22 144903.png" style="width: 955px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/113294iD2F440B97D7C9257/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-08-22 144903.png" alt="Screenshot 2024-08-22 144903.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 19:50:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526105#M87355</guid>
      <dc:creator>EGardner7</dc:creator>
      <dc:date>2024-08-22T19:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526114#M87356</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/774670"&gt;@EGardner7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the program, I believe this cannot take a function as I originally stated, how about this here:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;str(''.join([i for i in !YourFieldName! if i.isdigit()])) if ''.join([i for i in !YourFieldName! if i.isdigit()]) else None&lt;/LI-CODE&gt;&lt;P&gt;I'm not as versed in ArcMap and don't have access either, so if this doesn't end up working, I'm grasping for straws.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 19:55:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526114#M87356</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-22T19:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526142#M87363</link>
      <description>&lt;P&gt;Hi Cody this script finished loading but it did not return anything. Do you happen to know what might have gone wrong? Really appreciate all of your help with this&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 20:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526142#M87363</guid>
      <dc:creator>EGardner7</dc:creator>
      <dc:date>2024-08-22T20:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract numbers from a field in attribute table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526158#M87366</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/774670"&gt;@EGardner7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to speak with someone nearby and get access to their ArcMap to check some things, are you entering the function like this here?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CodyPatterson_0-1724359505850.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/113314iA7057E21E8B4084B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CodyPatterson_0-1724359505850.png" alt="CodyPatterson_0-1724359505850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the function will need to be in the pre-logic script code, and the extract_numbers in the assignment. Could you send a picture of this setup on your side?&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 20:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-extract-numbers-from-a-field-in-attribute/m-p/1526158#M87366</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-22T20:45:43Z</dc:date>
    </item>
  </channel>
</rss>

