<?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 Remove parentheses from data using field calculator. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381792#M30067</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good morning.&lt;/P&gt;&lt;P&gt;I am not real savvy with field calculator.&amp;nbsp; We have a couple fields that contain service address information.&amp;nbsp; Someone opted to add additional information enclosed by parentheses in this field.&amp;nbsp; I need to remove the parentheses and data within.&amp;nbsp; Any advice or suggestions appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Terry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jan 2018 14:32:54 GMT</pubDate>
    <dc:creator>TerryMergl</dc:creator>
    <dc:date>2018-01-16T14:32:54Z</dc:date>
    <item>
      <title>Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381792#M30067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good morning.&lt;/P&gt;&lt;P&gt;I am not real savvy with field calculator.&amp;nbsp; We have a couple fields that contain service address information.&amp;nbsp; Someone opted to add additional information enclosed by parentheses in this field.&amp;nbsp; I need to remove the parentheses and data within.&amp;nbsp; Any advice or suggestions appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Terry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381792#M30067</guid>
      <dc:creator>TerryMergl</dc:creator>
      <dc:date>2018-01-16T14:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381793#M30068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Terry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Using VBScript in the field calculator you just use Mid([yourfieldname], 1, (&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;InStr([yourfieldname],"(") - 1))&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will look in the thread for the first occurance of "(" and take everything before the "(" and use it for the field calc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:43:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381793#M30068</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-01-16T14:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381794#M30069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Terry a little function for the field calculator&lt;/P&gt;&lt;P&gt;Python parser of course&lt;/P&gt;&lt;P&gt;expression box &amp;nbsp; ....&amp;nbsp; brace(!YourFieldNameHere!)&lt;/P&gt;&lt;P&gt;code block&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;brace&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"""replace brackets"""&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'['&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;']'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'{'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'('&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;')'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; a&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fld&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fld&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;P&gt;of course you are putting the result in a new text field of appropriate width&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:35:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381794#M30069</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T17:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381795#M30070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; What about the data within?&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;I need to remove the parentheses and data within&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 15:05:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381795#M30070</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-01-16T15:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381796#M30071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert.&amp;nbsp; I'll give it a shot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 15:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381796#M30071</guid>
      <dc:creator>TerryMergl</dc:creator>
      <dc:date>2018-01-16T15:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381797#M30072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Dan.&lt;/P&gt;&lt;P&gt;What happened is when the service address got populated, someone added additional info between the parentheses in the same field, rather than using an address2 field &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;I don't need to save that info, just remove it.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 15:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381797#M30072</guid>
      <dc:creator>TerryMergl</dc:creator>
      <dc:date>2018-01-16T15:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381798#M30073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ahh missed that bit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 15:41:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381798#M30073</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T15:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381799#M30074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;well the other function you might use.... but&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keep between the brackets&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fld &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"some stuff (the stuff) with more"&lt;/SPAN&gt;

fld&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;")"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"("&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# yields&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'the stuff'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# just replace fld with !YourFieldName!&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dump between the brackets&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fld &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"some stuff (the stuff) with more"&lt;/SPAN&gt;

fld&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"("&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; fld&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;")"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'some stuff with more'&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:36:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381799#M30074</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T17:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381800#M30075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the Python interpreter, import the regular expression module (re) in the pre-logic script code block (click on Show Codeblock to open this):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;import re&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;&lt;/P&gt;&lt;P&gt;Then use a substitution along the lines of&amp;nbsp;this:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;re.sub(r"\([^\)]+\)", "", !ServiceAddr!)&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;&lt;/P&gt;&lt;P&gt;Should work fine with multiple pairs of parentheses but will likely need to be tweaked if you've got nested pairs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 16:53:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381800#M30075</guid>
      <dc:creator>JamesMacKay3</dc:creator>
      <dc:date>2018-01-16T16:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381801#M30076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you missed the bit I did earlier... the stuff between the braces needs to be removed as well &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 16:57:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381801#M30076</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T16:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381802#M30077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Actually James's regex gets all the string(s) between the ()s. RegEx is very powerful for stuff like this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 17:11:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381802#M30077</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-01-16T17:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove parentheses from data using field calculator.</title>
      <link>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381803#M30078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, I used to use them, but they changed in python 3.x so I just lost track of what applied to where&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 17:15:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remove-parentheses-from-data-using-field/m-p/381803#M30078</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T17:15:18Z</dc:date>
    </item>
  </channel>
</rss>

