<?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 How to remove first character from every row of an attribute field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558403#M43634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to Python and, as you can probably guess, I am having issue with some code I'm attempting to write.&amp;nbsp; The following will describe what I am attempting to do, and hopefully you wonderful people can tell me what I'm doing wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a point feature class with an attribute field called "STOINLET_I."&amp;nbsp; The field looks like this, and has about 2000 entries (rows):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0002&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0004&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a screenshot, to help better articulate the feature class:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26495[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I am attempting to do with this script is remove the first character in every row of the field so that the "P" no longer exists, which would leave me with this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0002&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0004&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am confident that the first section of code runs successfully.&amp;nbsp; The problem lies within the cursor, but I cannot figure out where.&amp;nbsp; I know this should be easy, but any help would be sincerely appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, string, os, fileinput from arcpy import env env.workspace = "desired workspace" env.overwriteOutput = True fc = "desired feature class" verification = arcpy.Exists (fc) print verification del verification&amp;nbsp;&amp;nbsp; cursor = arcpy.da.UpdateCursor (fc, ["STOINLET_I"]) for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; row.Replace(row[0:],'') del row del cursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2013 13:53:47 GMT</pubDate>
    <dc:creator>BrendanWhite1</dc:creator>
    <dc:date>2013-08-06T13:53:47Z</dc:date>
    <item>
      <title>How to remove first character from every row of an attribute field</title>
      <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558403#M43634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to Python and, as you can probably guess, I am having issue with some code I'm attempting to write.&amp;nbsp; The following will describe what I am attempting to do, and hopefully you wonderful people can tell me what I'm doing wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a point feature class with an attribute field called "STOINLET_I."&amp;nbsp; The field looks like this, and has about 2000 entries (rows):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0002&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDIN-0004&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a screenshot, to help better articulate the feature class:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26495[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I am attempting to do with this script is remove the first character in every row of the field so that the "P" no longer exists, which would leave me with this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0002&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIN-0004&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am confident that the first section of code runs successfully.&amp;nbsp; The problem lies within the cursor, but I cannot figure out where.&amp;nbsp; I know this should be easy, but any help would be sincerely appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, string, os, fileinput from arcpy import env env.workspace = "desired workspace" env.overwriteOutput = True fc = "desired feature class" verification = arcpy.Exists (fc) print verification del verification&amp;nbsp;&amp;nbsp; cursor = arcpy.da.UpdateCursor (fc, ["STOINLET_I"]) for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; row.Replace(row[0:],'') del row del cursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 13:53:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558403#M43634</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2013-08-06T13:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove first character from every row of an attribute field</title>
      <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558404#M43635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have trouble with this line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row.Replace(row[0:],'')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You are getting the whole string with [0:]. Based on the sample data, use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row.Replace('P', '')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 14:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558404#M43635</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2013-08-06T14:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove first character from every row of an attribute field</title>
      <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558405#M43636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for such a quick response, Jim. I ran the code with Jim's suggestion, and the code is still kicking up an error, seen here (shell text from IDLE):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "filepath/PythonScript.py", line 16, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; row.Replace('P','')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'list' object has no attribute 'Replace'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based upon a quick google search it seems as though people receive this error when their indentation is off, or when filepaths are messy. I managed to account for the filepath with the "verification =" line of code. The blue text reading "true" above confirms the filepath. Also, the spacing in this code is not complicated, and from what I can tell, is correct. Are there any suggestions on how to alleviate this error?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 15:05:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558405#M43636</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2013-08-06T15:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove first character from every row of an attribute field</title>
      <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558406#M43637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="plain" name="code"&gt;cursor = arcpy.da.UpdateCursor (fc, ["STOINLET_I"]) for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow([row[0][1:]])&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 15:33:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558406#M43637</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2013-08-06T15:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove first character from every row of an attribute field</title>
      <link>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558407#M43638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;cursor = arcpy.da.UpdateCursor (fc, ["STOINLET_I"])
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow([row[0][1:]])&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;THIS WORKED! Thank you so much.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:06:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-remove-first-character-from-every-row-of-an/m-p/558407#M43638</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2021-12-12T00:06:17Z</dc:date>
    </item>
  </channel>
</rss>

