<?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: How to change existing field values with sequential numbers  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161111#M12318</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eyad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will each new record simply increment by 1 (i.e. WBD001-1,WBD001-2).&amp;nbsp; Will WBD001 ever change for other features?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Dec 2019 12:47:33 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2019-12-23T12:47:33Z</dc:date>
    <item>
      <title>How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161110#M12317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;I have a feature class that has a field in attribute table with values like WBD001. Now I am cutting this feature into a parking lots and want to assign each parking lot a value like WBD001-1,WBD001-2, ...n.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there any code to do so; considering I am working on a versioned GDB and don't have the privilege to add another field to make concatenation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Dec 2019 07:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161110#M12317</guid>
      <dc:creator>eyadghatasheh</dc:creator>
      <dc:date>2019-12-22T07:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161111#M12318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eyad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will each new record simply increment by 1 (i.e. WBD001-1,WBD001-2).&amp;nbsp; Will WBD001 ever change for other features?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2019 12:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161111#M12318</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2019-12-23T12:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161112#M12319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as you said;&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;each new record simply increment by 1 and will not ever change for other feature.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2019 07:41:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161112#M12319</guid>
      <dc:creator>eyadghatasheh</dc:creator>
      <dc:date>2019-12-24T07:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161113#M12320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use the following to do this:&lt;/P&gt;&lt;P&gt;&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;gen&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;x&lt;SPAN class="operator 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="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;yield&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"WBD001-{0}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;x&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        x&lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;

g &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gen&lt;SPAN class="punctuation token"&gt;(&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;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/476899_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161113#M12320</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T08:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161114#M12321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/46758" target="_blank"&gt;eyad ghatasheh&lt;/A&gt;&amp;nbsp;and &lt;A href="https://community.esri.com/migrated-users/8586" target="_blank"&gt;Jake Skinner&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think in Jake's example he used the attribute calculation rule syntax&amp;nbsp;that might not work in a normal field calculation. In case you have different original codes and want to use a sequential number within each group (original code) like shown below:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/477013_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&amp;nbsp;it might be easier to create a small script and run that in the Python window:&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; &lt;SPAN class="string token"&gt;'the name of your featureclas'&lt;/SPAN&gt;
fld_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'the name of your field'&lt;/SPAN&gt;

dct &lt;SPAN class="operator 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="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; curs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; curs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        code &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&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="keyword token"&gt;if&lt;/SPAN&gt; code &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dct&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            seq &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dct&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;code&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            seq &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        dct&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;code&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; seq
        row&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="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{0}-{1}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;code&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; seq&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        curs&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&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;/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;Please note that this will overwrite the original code. It would be a good idea to create a copy of the data&amp;nbsp;for safety before running the script.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:28:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161114#M12321</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T08:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161115#M12322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a million&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in fact, the test field (CAD_Design_RoomID) that I have contains "Null" for all records. and I want to generate a sequential codes for each parking Lot building on its location as each bulk of parking lots exist in an area named as&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;WBD001,&amp;nbsp;&lt;SPAN&gt;WBD002 ...etc. so each subset of parking lots should be given sequential codes like&amp;nbsp;WBD001-1,&amp;nbsp;WBD001-2 based on a &lt;STRONG&gt;selection&amp;nbsp;&lt;/STRONG&gt;as these parking lots are part of a FC that contains many other features and not only parking lots.&amp;nbsp;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/477149_Parkings.jpg" /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Dec 2019 12:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161115#M12322</guid>
      <dc:creator>eyadghatasheh</dc:creator>
      <dc:date>2019-12-29T12:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to change existing field values with sequential numbers</title>
      <link>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161116#M12323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/people/abujenine" target="_blank"&gt;abujenine&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you want to work with selections and you don't have any information in the field yet (no need to create a backup), you can do this. Select the features (select by location I assume), and do the following calculation based on this support document:&amp;nbsp;&lt;A class="link-titled" href="https://support.esri.com/en/technical-article/000011137" title="https://support.esri.com/en/technical-article/000011137" rel="nofollow noopener noreferrer" target="_blank"&gt;How To: Create sequential numbers in a field using Python in the Field Calculator&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/477158_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the Code block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;rec&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;autoIncrement&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;prefix&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;global&lt;/SPAN&gt; rec
    pStart &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
    pInterval &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rec &lt;SPAN class="operator 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;
        rec &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pStart
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        rec &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; pInterval
    &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;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;prefix&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rec&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;/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;and this should be your calculation:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;autoIncrement&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"WBD001"&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change the prefix for each selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:28:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-change-existing-field-values-with/m-p/161116#M12323</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T08:28:39Z</dc:date>
    </item>
  </channel>
</rss>

