<?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: Python String Format using a placeholder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543448#M42382</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much Joshua! It worked! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Mar 2020 14:03:15 GMT</pubDate>
    <dc:creator>NataliaGutierrez1</dc:creator>
    <dc:date>2020-03-25T14:03:15Z</dc:date>
    <item>
      <title>Python String Format using a placeholder</title>
      <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543445#M42379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\APRX_MXDS\USA_Parcels_2019_Project\Test.gdb"&lt;/SPAN&gt;

List_dissolve_fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFeatureClasses&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*Dissolve"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# get a list of feature classes that end with "Dissolve"&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;"CO_NO"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"COUNTY_NAME"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# List of fields in test.gdb&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; fc &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; List_dissolve_fc&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# Loop through each feature class in the list&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; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Loop through each feature&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            row&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="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{[-17]}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Update each feature in field [1] "COUNTY_NAME" using the name of the feature class without the last 17 characters. For example: walton_2019pin_Dissolve would be walton.&lt;/SPAN&gt;
            cursor&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;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to loop through feature classes and in each feature class I need to update the field "COUNTY_NAME" with the name of the feature class. The problem is, that the name of the feature class is too long and I don't need to include the last 17 characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp;"walton_2019pin_Dissolve" is the name of one feature class and I only want to use "walton" in the field names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see in the script this is written in line 12.&lt;/P&gt;&lt;P&gt;This method is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How could I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Natalia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:31:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543445#M42379</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2021-12-11T23:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python String Format using a placeholder</title>
      <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543446#M42380</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;row&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="operator token"&gt;=&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;fc&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;&lt;SPAN class="number token"&gt;17&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2020 23:43:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543446#M42380</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-24T23:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python String Format using a placeholder</title>
      <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543447#M42381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While &lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;‌`s suggestion is spot on, in fact I credit him for showing me how to use format(), I've been trying to use python f strings described here:&amp;nbsp;&amp;nbsp;&lt;A class="link-titled" href="https://realpython.com/python-f-strings/" title="https://realpython.com/python-f-strings/"&gt;https://realpython.com/python-f-strings/&lt;/A&gt;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2020 04:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543447#M42381</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-03-25T04:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Python String Format using a placeholder</title>
      <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543448#M42382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much Joshua! It worked! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2020 14:03:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543448#M42382</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-03-25T14:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python String Format using a placeholder</title>
      <link>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543449#M42383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Than you Joe for sharing the link. There's very good info. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2020 14:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-string-format-using-a-placeholder/m-p/543449#M42383</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-03-25T14:03:50Z</dc:date>
    </item>
  </channel>
</rss>

