<?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: Replacing field values for pre direction field in ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733752#M56892</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code worked.&amp;nbsp; I will use the same syntax for the road types and post directional.&amp;nbsp; Thank you very much.&amp;nbsp; If you have any alternative solutions that achieve the same result, please let me know.&amp;nbsp; I am always looking for ways to improve my python code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Jun 2020 18:05:39 GMT</pubDate>
    <dc:creator>TyquinWashington</dc:creator>
    <dc:date>2020-06-01T18:05:39Z</dc:date>
    <item>
      <title>Replacing field values for pre direction field in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733749#M56889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to replace the values in my predirection field in ArcMap using the field calculator.&amp;nbsp; Here is my sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def predir(field):&lt;BR /&gt; if "S" in fields:&lt;BR /&gt; return field.replace("S","South")&lt;BR /&gt; elif "E" in fields:&lt;BR /&gt; return field.replace("E","EAST")&lt;BR /&gt; elif "W" in fields:&lt;BR /&gt; return field.replace("W", "WEST")&lt;BR /&gt; elif "N" in fields:&lt;BR /&gt; return field.replace("N", "NORTH")&lt;BR /&gt; elif "NE" in fields:&lt;BR /&gt; return field.replace("NE", "NORTHEAST")&lt;BR /&gt; elif "NW" in fields:&lt;BR /&gt; return field.replace("NW", "NORTHWEST")&lt;BR /&gt; elif "SE" in fields:&lt;BR /&gt; return field.replace("SE", "SOUTHEAST")&lt;BR /&gt; elif "SW" in fields:&lt;BR /&gt; return field.replace("SW", "SOUTHWEST")&lt;BR /&gt;else:&lt;BR /&gt; return field &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the following error:&lt;/P&gt;&lt;P&gt;Failed to execute. Parameters are not valid&lt;/P&gt;&lt;P&gt;Error 000989: Python syntax error: Parsing error SyntaxError:Invalid syntax(line18)&lt;/P&gt;&lt;P&gt;Failed to execute (Calculate Field).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are Null values in the field, but they need to be there for NextGen 911 purposes.&amp;nbsp; Any suggestions?&amp;nbsp; I was thinking of using a similar syntax for replacing my post direction and street type values as well.&amp;nbsp; Eventually I will need to put a script together that does all this for my street center lines and structures.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2020 14:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733749#M56889</guid>
      <dc:creator>TyquinWashington</dc:creator>
      <dc:date>2020-06-01T14:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing field values for pre direction field in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733750#M56890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tyquin - I'll be the first to say I'm am NOT a Python programmer by any stretch of the imagination but in researching your question a little bit, I learned that Python considers the NULL value to be NONE in Python.&amp;nbsp; Continuing I believe based on my limited research, you'll need to create a "search cursor" to ignore the NONE/NULL value in the field.&amp;nbsp; If it finds one, it ignores it and goes to the next roll/column.&amp;nbsp; If there are no NULL/NONE in the field then it executes your script portion above.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm tagging &lt;A href="https://community.esri.com/migration-blogpost/10572"&gt;Jeff Bigos's Blog&lt;/A&gt;‌ as he is Esri Training Services "python guru" to see if he has a more detailed answer than I but it seems to make sense...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2020 16:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733750#M56890</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2020-06-01T16:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing field values for pre direction field in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733751#M56891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&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;predir&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    name_mapping &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"S"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SOUTH"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"SW"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SOUTHWEST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"W"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"WEST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"NW"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NORTHWEST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"N"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NORTH"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"NE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NORTHEAST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"E"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"EAST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"SE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SOUTHEAST"&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; name_mapping&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; name_mapping&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; field&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;/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>Sun, 12 Dec 2021 07:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733751#M56891</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T07:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing field values for pre direction field in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733752#M56892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code worked.&amp;nbsp; I will use the same syntax for the road types and post directional.&amp;nbsp; Thank you very much.&amp;nbsp; If you have any alternative solutions that achieve the same result, please let me know.&amp;nbsp; I am always looking for ways to improve my python code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2020 18:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacing-field-values-for-pre-direction-field-in/m-p/733752#M56892</guid>
      <dc:creator>TyquinWashington</dc:creator>
      <dc:date>2020-06-01T18:05:39Z</dc:date>
    </item>
  </channel>
</rss>

