<?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: Removing Leading Numbers From a Field in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168995#M54562</link>
    <description>&lt;P&gt;Tract codes are digits, but they must be text to do a join to another table that has a tract text field.&amp;nbsp; To create a text field Add a field "tract1" as type text, and populate it with Calculate Field (python syntax: &lt;STRONG&gt;str(int(!TRACT!)&lt;/STRONG&gt; to a) make it integer and b) convert to text)&lt;/P&gt;&lt;P&gt;Getting data to load as text from a csv is tricky, the usual method is to add a row of dummy data to force type, for example put "aaaaaa" in the place of the tract column. The csv type issue is similar to issues loading data from excel&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/excel/work-with-excel-in-arcgis-pro.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/help/data/excel/work-with-excel-in-arcgis-pro.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I think we have helped you as much as you can until you have data in text.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 19:01:02 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2022-04-28T19:01:02Z</dc:date>
    <item>
      <title>Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168761#M54521</link>
      <description>&lt;P&gt;I have a tracts field (Tract) which I want to strip off the first 4 numbers in an attribute table.&amp;nbsp; I created a new field (Tract2) for it.&amp;nbsp; I've tried several commands without success using the field calculator.&amp;nbsp; I'm receiving errors&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 13:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168761#M54521</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T13:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168767#M54522</link>
      <description>&lt;P&gt;What have you tried so far? And what errors do you get? What kind of field is it, string or numeric?&lt;/P&gt;&lt;P&gt;Assuming a string, you could try either of these approaches.&lt;/P&gt;&lt;P&gt;Arcade:&lt;/P&gt;&lt;PRE&gt;Right($feature.Tract, Count($feature.Tract) - 4)&lt;/PRE&gt;&lt;P&gt;Python:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;!Tract![4:]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Tweaked the Python bit. Thanks, Curt! Also, could&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/582456"&gt;@jfkuhn&lt;/a&gt;&amp;nbsp;please elaborate on the intended output here? Do you want the first four characters to end up in the new field, or do you want the remaining characters after the first 4 are removed?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:57:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168767#M54522</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168790#M54530</link>
      <description>&lt;P&gt;Census tract codes are text fields, so your syntax would work.&lt;/P&gt;&lt;P&gt;However, your code gets the &lt;EM&gt;last&lt;/EM&gt; four numbers. To get the first 4 numbers you can use the Left function, or in python use the slice expression [:4].&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168790#M54530</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-04-28T14:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168802#M54532</link>
      <description>&lt;P&gt;D'oh! Thank you for catching that. Although, thinking about it more, it's not totally clear if "strip off" means that the first 4 numbers are being removed from the output, or if it's the first 4 that they want to keep. I guess [4:] would be the other way.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:55:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168802#M54532</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T14:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168815#M54537</link>
      <description>&lt;P&gt;1st 4 number will be removed&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:18:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168815#M54537</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168821#M54538</link>
      <description />
      <pubDate>Thu, 28 Apr 2022 15:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168821#M54538</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168826#M54539</link>
      <description>&lt;P&gt;I think this could be done in Arcade, but Python is MUCH easier for this task, use&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;suggestion:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Tract[4:]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168826#M54539</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-04-28T15:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168827#M54540</link>
      <description>&lt;P&gt;Ah, that usually happens if there's a null value in the sample row the tool uses to validate your expression. We need to be sure we handle null values in our expression.&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp;&lt;STRONG&gt;Left(string, x)&amp;nbsp;&lt;/STRONG&gt;returns the left-most x characters, so it's going to preserve the left characters, rather than remove them.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var t = $feature['Tract']

if (IsEmpty(t)){
    return ''
} else {
    return Right(t, Count(t)-4)
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:29:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168827#M54540</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168828#M54541</link>
      <description>&lt;P&gt;For some reason what was suggested didn't work.&amp;nbsp; See my screen capture&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168828#M54541</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168830#M54542</link>
      <description>&lt;P&gt;I hate that "circus language" with a white heat, but then I'm a desktop person (no JavaScript for me) and I'm old and hate being forced to learn yet another thing.&lt;/P&gt;&lt;P&gt;Python example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# expression
f(!Tract!)
# code block
def f(tract):
    try:
        return tract[4:]
    except:
        pass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:35:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168830#M54542</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-04-28T15:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168832#M54543</link>
      <description>&lt;P&gt;Still get errors.&amp;nbsp; See attached&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:37:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168832#M54543</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168833#M54544</link>
      <description>&lt;P&gt;It's not horrible if you come from a JS background, but I would agree that if you've got the option to use Python, it's usually the better choice. "Couldn't I just use Python for this?" is something I utter pretty frequently when I'm working with web layers.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:38:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168833#M54544</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T15:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168835#M54545</link>
      <description>&lt;P&gt;Hrm. Can you confirm whether tract is coming in as a string or number? In any case, try explicitly changing it. Replace line 1 of the expression with this:&lt;/P&gt;&lt;PRE&gt;var t = Text($feature['Tract'])&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:42:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168835#M54545</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T15:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168839#M54546</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/1325" target="_self"&gt;&lt;SPAN class=""&gt;curtvprice&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example also produced an error&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:44:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168839#M54546</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168842#M54548</link>
      <description>&lt;P&gt;Read the fine manual for the Calculate Field tool for more details on how to use the expression and code block.&lt;/P&gt;&lt;P&gt;Also if your tract is indeed a number (this is incorrect, you should try to get them read as text) you can string it to fix the problem, convert to string first, by wrapping the expression like this: &lt;STRONG&gt;f(str(!Tract!))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Make sure your Tract2 is a text field or you will lose leading zeros.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:51:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168842#M54548</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-04-28T15:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168844#M54549</link>
      <description>&lt;P&gt;If your data are numbers, this Python expression should work without a code block. Assuming Tract2 is a text field, which it should be.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;str(!Tract!)[4:]&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168844#M54549</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-04-28T15:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168849#M54550</link>
      <description>&lt;P&gt;That work accept it puts a .0 at the end.&amp;nbsp; I need it without a .0 so I can join it with another table&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168849#M54550</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T15:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168851#M54551</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;The following work except it puts a .0 in at the end.&amp;nbsp; I need it without the .0 so I can join it with another table.&lt;/P&gt;&lt;P&gt;If your data are numbers, this Python expression should work without a code block. Assuming Tract2 is a text field, which it should be.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;str(!Tract!)[4:]&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/td-p/1168761/page/2#" target="_blank" rel="noopener"&gt;Add tags&lt;/A&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Apr 2022 16:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168851#M54551</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T16:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168857#M54553</link>
      <description>&lt;PRE&gt;&lt;STRONG&gt;str(!Tract!)[4:-2]&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;Can I ask where the original source of this data is? Did you by chance import a CSV or text file into Pro or something? It sounds an awful lot like a text-based data source being incorrectly interpreted as a number, which happens when a field only contains digits.&lt;/P&gt;&lt;P&gt;This is beyond the scope of the original question, but you may need to address upstream issues with how your data is imported. As&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1325"&gt;@curtvprice&lt;/a&gt;&amp;nbsp;notes, it really is&amp;nbsp;&lt;EM&gt;supposed&amp;nbsp;&lt;/EM&gt;to be a text field.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 16:08:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168857#M54553</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-28T16:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Leading Numbers From a Field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168977#M54558</link>
      <description>&lt;P&gt;&amp;nbsp; The original data source is numerical (double) so when I create a text field it puts .0 at the end.&amp;nbsp; The data is a shape file.&amp;nbsp; The .0 prevents me from joining it with the Census Tract data I downloaded.&amp;nbsp; So, how can drop the .0 in the newly created text Tract Field from Python?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:30:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/removing-leading-numbers-from-a-field/m-p/1168977#M54558</guid>
      <dc:creator>jfkuhn</dc:creator>
      <dc:date>2022-04-28T18:30:28Z</dc:date>
    </item>
  </channel>
</rss>

