<?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: code for changing nulls to blanks in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356907#M1178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By 'blank' you mean...? It also depends on the data type of your field. The easy way: if your field is a string you can do the following in a field calculator (to be safe: create a new field, then use this to get the values into it, then delete the old field; but you can just have the field calculate on itself):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;STRONG&gt;Pre-Logic Script Code:&lt;/STRONG&gt;
def nullToBlank(fieldValue):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldValue == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ' ' # returns a string with just a space in it (looks blank).
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fieldValue

&lt;STRONG&gt;Expression:&lt;/STRONG&gt;
nullToBlank(!oldField!)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The hard way would be to make a Python script that iterates through all the rows (using UpdateCursor) and replaces the values that are == None with something...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:41:28 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2021-12-11T16:41:28Z</dc:date>
    <item>
      <title>code for changing nulls to blanks</title>
      <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356906#M1177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: alnesbit&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used to do a bit with VBA but I have no idea how to do anything in python. I'm wondering if anyone could help me write a little code to change all of my null values to blanks in all of my fields in my feature classes? &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/28208-show-null-values-as-blank"&gt;http://forums.arcgis.com/threads/28208-show-null-values-as-blank&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jul 2011 12:25:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356906#M1177</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-07-15T12:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: code for changing nulls to blanks</title>
      <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356907#M1178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By 'blank' you mean...? It also depends on the data type of your field. The easy way: if your field is a string you can do the following in a field calculator (to be safe: create a new field, then use this to get the values into it, then delete the old field; but you can just have the field calculate on itself):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;STRONG&gt;Pre-Logic Script Code:&lt;/STRONG&gt;
def nullToBlank(fieldValue):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldValue == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ' ' # returns a string with just a space in it (looks blank).
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fieldValue

&lt;STRONG&gt;Expression:&lt;/STRONG&gt;
nullToBlank(!oldField!)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The hard way would be to make a Python script that iterates through all the rows (using UpdateCursor) and replaces the values that are == None with something...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356907#M1178</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T16:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: code for changing nulls to blanks</title>
      <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356908#M1179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: alnesbit&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;By 'blank' you mean...? It also depends on the data type of your field. The easy way: if your field is a string you can do the following in a field calculator (to be safe: create a new field, then use this to get the values into it, then delete the old field; but you can just have the field calculate on itself):&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;STRONG&gt;Pre-Logic Script Code:&lt;/STRONG&gt;
def nullToBlank(fieldValue):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldValue == None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ' ' # returns a string with just a space in it (looks blank).
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fieldValue

&lt;STRONG&gt;Expression:&lt;/STRONG&gt;
nullToBlank(!oldField!)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The hard way would be to make a Python script that iterates through all the rows (using UpdateCursor) and replaces the values that are == None with something...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for getting back to me. Yes, by blank I mean ' ' and my fields are string fields. I'm having trouble using your code and I think it's because I'm so rusty at using code. I copied it and put the top part in the Pre-Logic Script code box and I put the bottom one in the box below that says "PoleUseType = " (which is my field name I'm calculating). What do I need to change?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is a lot like what I usually do - select values that are Null for each field, one by one, then calculate those selected records to ' '. But at least it would save me one step of selecting the values first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The hard way-you mention creating a python script. I think that is what I am ultimately trying to find. Do you have any idea how I could start to create a script like that? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:41:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356908#M1179</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T16:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: code for changing nulls to blanks</title>
      <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356909#M1180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Didn't test it, but this code should "blank-ify" any NULL text fields:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#One way...
txtFieldList = arcpy.ListFields(myFC, "", "STRING")
updateRows = arcpy.UpdateCursor(myFC)
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp; for txtField in txtFieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateRow.isNull(txtField.name):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setValue(txtField.name, '')
&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Another way that might? be faster/better:
txtFieldList = arcpy.ListFields(myFC, "", "STRING")
for txtField in txtFieldList:
&amp;nbsp;&amp;nbsp; updateRows = arcpy.UpdateCursor(myFC, txtField.name + " IS NULL", "", txtField.name)
&amp;nbsp;&amp;nbsp; for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setValue(txtField.name, '')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:41:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356909#M1180</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T16:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: code for changing nulls to blanks</title>
      <link>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356910#M1181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: alnesbit&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Didn't test it, but this code should "blank-ify" any NULL text fields:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#One way...
txtFieldList = arcpy.ListFields(myFC, "", "STRING")
updateRows = arcpy.UpdateCursor(myFC)
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp; for txtField in txtFieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateRow.isNull(txtField.name):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setValue(txtField.name, '')
&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Another way that might? be faster/better:
txtFieldList = arcpy.ListFields(myFC, "", "STRING")
for txtField in txtFieldList:
&amp;nbsp;&amp;nbsp; updateRows = arcpy.UpdateCursor(myFC, txtField.name + " IS NULL", "", txtField.name)
&amp;nbsp;&amp;nbsp; for updateRow in updateRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.setValue(txtField.name, '')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the second code because you said it might be faster/better. And it worked like a charm! thank you so much!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:41:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/code-for-changing-nulls-to-blanks/m-p/356910#M1181</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T16:41:37Z</dc:date>
    </item>
  </channel>
</rss>

