<?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: Remove all numbers/integer values from multiple fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181209#M13926</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was always told to avoid functions when using field calculator and therefor never done it. So i am not sure how to use the function with field calculator. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Aug 2019 15:31:30 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2019-08-23T15:31:30Z</dc:date>
    <item>
      <title>Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181207#M13924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some fields with alphabetic and numbers i want to remove all the numbers. I have tried some things but the issue i have is that the numbers are between the alphabetic text for example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Homeowners field&lt;/P&gt;&lt;P&gt;"Homeowners 456 Exempt",---&amp;gt; Homeowners Exempt&lt;/P&gt;&lt;P&gt;"456 Homeowners Exempt"--&amp;gt; Homeowners Exempt&lt;/P&gt;&lt;P&gt;"Homeowners Exempt 456" --&amp;gt; Homeowners Exempt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Irrigation&lt;/P&gt;&lt;P&gt;Hill Irrigation #2 Dist --&amp;gt; Hill Irrigation Dist&lt;/P&gt;&lt;P&gt;#2Hill Irrigation Dist --&amp;gt; Hill Irrigation Dist&lt;/P&gt;&lt;P&gt;Hill Irrigation Dist#2 --&amp;gt; Hill Irrigation Dist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drain&lt;/P&gt;&lt;P&gt;High Drain #2 Dist --&amp;gt; High Drain Dist&lt;/P&gt;&lt;P&gt;#2High Drain Dist --&amp;gt; High Drain Dist&lt;/P&gt;&lt;P&gt;High Drain Dist #2--&amp;gt; High Drain Dist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried .strip('0123456789. -#') but it only removes them from the beginning and end not in between.&lt;/P&gt;&lt;P&gt;Ive been working with this but i can't seem to get right. I would appreciate any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc = r"C:\Temp\Lyr1"
fields = ['HomeOwners', 'Irrigation', 'Drain']
exp = ''.join(c for c in fields if not c.isnumeric())
arcpy.management.CalculateField(fc, fields, exp, "PYTHON3")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;get the following error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:15:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181207#M13924</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T09:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181208#M13925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# --- the key is the list of the string&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# dump = list('0123456789#')&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# dump&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '#']&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;# --- now make the function&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;dump_stuff&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""add to dump if needed"""&lt;/SPAN&gt;
    dump &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;'&lt;SPAN class="number token"&gt;0123456789&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;#')&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fld &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dump&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    

&lt;SPAN class="comment token"&gt;# ---- now test it&lt;/SPAN&gt;

a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; "some &lt;SPAN class="comment token"&gt;#1 test in 234 field"&lt;/SPAN&gt;
dump_stuff&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'some  test in  field'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181208#M13925</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T09:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181209#M13926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was always told to avoid functions when using field calculator and therefor never done it. So i am not sure how to use the function with field calculator. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 15:31:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181209#M13926</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2019-08-23T15:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181210#M13927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Speaking just to the code snippet you provided, the Field Calculator acts on one field at a time, you can't pass it a list of fields to operate on independently.&amp;nbsp; If you want to process multiple fields using the same method/approach, you will need to loop over a list of fields and call Field Calculate on each one.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\Temp\Lyr1"&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'HomeOwners'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Irrigation'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Drain'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; fld &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    exp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# some expression that is formatted correctly&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fld&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; exp&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:15:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181210#M13927</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T09:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181211#M13928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;It need not be a field calculator expression.&amp;nbsp; You can call that def within a loop that collects all your text fields in a featureclass.&amp;nbsp; Pass the field's name to the function and it work&amp;nbsp; with an updatecursor or the field calculator call as Joshua indicated.&amp;nbsp; The key is the function.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 20:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181211#M13928</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-08-23T20:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181212#M13929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to get to work with arcpy.da.UpdateCurosr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;def dump_stuff(fld):
    """add to dump if needed"""
    dump = list('0123456789#')
    return "".join([i for i in fld if i not in dump])

with arcpy.da.UpdateCursor(fc, fld) as cursor:
    for row in cursor:
        s = row[0]
        row[0] = dump_stuff(row[0])
        row[1] = dump_stuff(row[1])
        row[2] = dump_stuff(row[2])
        cursor.updateRow(row)
del cursor
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181212#M13929</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T09:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181213#M13930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on what you stated that you can't pass a list of fields. Here is what i came up with, correct?&lt;/P&gt;&lt;P&gt;This took about 2.06 mins where using arcpy.da.UpdateCursor only took 4 seconds. The only issue with the code below is that it removed everything that was not alphabet character but it didn't leave a space, like so. I need there to be a space.&lt;/P&gt;&lt;P&gt;Drain&lt;/P&gt;&lt;P&gt;High Drain #2 Dist --&amp;gt; HighDrainDist&lt;/P&gt;&lt;P&gt;#2High Drain Dist --&amp;gt; HighDrainDist&lt;/P&gt;&lt;P&gt;High Drain Dist #2--&amp;gt; HighDrainDist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code I used.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc = r"C:\Temp\Lyr1"
fields = ['HomeOwners', 'Irrigation', 'Drain']

for fld in fields:
    exp = "''.join([i for i in !HomeOwners! if i.isalpha()])"
    arcpy.management.CalculateField(fc, 'HomeOwners', exp, "PYTHON3")

    exp = "''.join([i for i in !Irrigation! if i.isalpha()])"
    arcpy.management.CalculateField(fc, 'Irrigation', exp, "PYTHON3")

    exp = "''.join([i for i in !Drain! if i.isalpha()])"
    arcpy.management.CalculateField(fc, 'Drain', exp, "PYTHON3")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181213#M13930</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T09:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all numbers/integer values from multiple fields</title>
      <link>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181214#M13931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"''.join([i for i in !Irrigation! if any((i.isalpha(), i.isspace()))]).strip()"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(and, by the way, I think you have already shown using a cursor is much more efficient)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 22:37:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-all-numbers-integer-values-from-multiple/m-p/181214#M13931</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-23T22:37:33Z</dc:date>
    </item>
  </channel>
</rss>

