Converting none to zero (0) in geodatabase table using ArcPy?












1














I have an attribute table looks like this



enter image description here



How do I convert Nulls into 0?



I've tried to set this table non nullable type but got this:



enter image description here



while the official doc says this:



enter image description here



At least one of them is wrong.



Then I tried many ways to do the job, like this:



RValues=arcpy.SearchCursor(sr)

for RValue in RValues:
#print (RValue.getValue(field))
if RValue.getValue(field) == None:
#print (RValue.getValue(field))
return 0
else
return
float(RValue.getValue(field))

print(RValue.getValue(field))


This gives error 999999, don't know why, possible a bug.



Then I tried this:



RValues=arcpy.SearchCursor(sr)
print (RValues)

for RValue in RValues:
if RValue.getValue(field) == None:
print (RValue.getValue(field))
arcpy.CalculateField_management(sr, "RValue", esp, "PYTHON3")
print (RValue.getValue(field))


Well, the first print gives a



<geoprocessing cursor object object at 0x0000025F5C161E70>


the second print does isolate all none items, as there is no null in python.



Here is the trick:



the third print either gives error or turn everything into null or 0,focus on everything, expressions I use are as follows:



esp="!RValue!.replace(None, 0)"

esp2="!RValue! * 0"

esp3="set field = 0 where field is null"

esp4="NVL(RValue,0)"

esp5="select nvl(RValue, 0) from sr.RValue"

esp6="None"


How is that even possible when the if before it already isolate only those nones?



I got a warning of



Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique.


I'm very new to this form.So please forgive some beginner's fault.From what I saw it did bear some similarity to mine. But I do think the answers in mine is better.
If you have to join my question into his, please keep those answers.










share|improve this question









New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • also I've tried RValue.setValue(field,0) , also error 99999.
    – Karl Tian
    1 hour ago










  • so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
    – Karl Tian
    1 hour ago










  • Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
    – Andy
    1 hour ago
















1














I have an attribute table looks like this



enter image description here



How do I convert Nulls into 0?



I've tried to set this table non nullable type but got this:



enter image description here



while the official doc says this:



enter image description here



At least one of them is wrong.



Then I tried many ways to do the job, like this:



RValues=arcpy.SearchCursor(sr)

for RValue in RValues:
#print (RValue.getValue(field))
if RValue.getValue(field) == None:
#print (RValue.getValue(field))
return 0
else
return
float(RValue.getValue(field))

print(RValue.getValue(field))


This gives error 999999, don't know why, possible a bug.



Then I tried this:



RValues=arcpy.SearchCursor(sr)
print (RValues)

for RValue in RValues:
if RValue.getValue(field) == None:
print (RValue.getValue(field))
arcpy.CalculateField_management(sr, "RValue", esp, "PYTHON3")
print (RValue.getValue(field))


Well, the first print gives a



<geoprocessing cursor object object at 0x0000025F5C161E70>


the second print does isolate all none items, as there is no null in python.



Here is the trick:



the third print either gives error or turn everything into null or 0,focus on everything, expressions I use are as follows:



esp="!RValue!.replace(None, 0)"

esp2="!RValue! * 0"

esp3="set field = 0 where field is null"

esp4="NVL(RValue,0)"

esp5="select nvl(RValue, 0) from sr.RValue"

esp6="None"


How is that even possible when the if before it already isolate only those nones?



I got a warning of



Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique.


I'm very new to this form.So please forgive some beginner's fault.From what I saw it did bear some similarity to mine. But I do think the answers in mine is better.
If you have to join my question into his, please keep those answers.










share|improve this question









New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • also I've tried RValue.setValue(field,0) , also error 99999.
    – Karl Tian
    1 hour ago










  • so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
    – Karl Tian
    1 hour ago










  • Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
    – Andy
    1 hour ago














1












1








1







I have an attribute table looks like this



enter image description here



How do I convert Nulls into 0?



I've tried to set this table non nullable type but got this:



enter image description here



while the official doc says this:



enter image description here



At least one of them is wrong.



Then I tried many ways to do the job, like this:



RValues=arcpy.SearchCursor(sr)

for RValue in RValues:
#print (RValue.getValue(field))
if RValue.getValue(field) == None:
#print (RValue.getValue(field))
return 0
else
return
float(RValue.getValue(field))

print(RValue.getValue(field))


This gives error 999999, don't know why, possible a bug.



Then I tried this:



RValues=arcpy.SearchCursor(sr)
print (RValues)

for RValue in RValues:
if RValue.getValue(field) == None:
print (RValue.getValue(field))
arcpy.CalculateField_management(sr, "RValue", esp, "PYTHON3")
print (RValue.getValue(field))


Well, the first print gives a



<geoprocessing cursor object object at 0x0000025F5C161E70>


the second print does isolate all none items, as there is no null in python.



Here is the trick:



the third print either gives error or turn everything into null or 0,focus on everything, expressions I use are as follows:



esp="!RValue!.replace(None, 0)"

esp2="!RValue! * 0"

esp3="set field = 0 where field is null"

esp4="NVL(RValue,0)"

esp5="select nvl(RValue, 0) from sr.RValue"

esp6="None"


How is that even possible when the if before it already isolate only those nones?



I got a warning of



Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique.


I'm very new to this form.So please forgive some beginner's fault.From what I saw it did bear some similarity to mine. But I do think the answers in mine is better.
If you have to join my question into his, please keep those answers.










share|improve this question









New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have an attribute table looks like this



enter image description here



How do I convert Nulls into 0?



I've tried to set this table non nullable type but got this:



enter image description here



while the official doc says this:



enter image description here



At least one of them is wrong.



Then I tried many ways to do the job, like this:



RValues=arcpy.SearchCursor(sr)

for RValue in RValues:
#print (RValue.getValue(field))
if RValue.getValue(field) == None:
#print (RValue.getValue(field))
return 0
else
return
float(RValue.getValue(field))

print(RValue.getValue(field))


This gives error 999999, don't know why, possible a bug.



Then I tried this:



RValues=arcpy.SearchCursor(sr)
print (RValues)

for RValue in RValues:
if RValue.getValue(field) == None:
print (RValue.getValue(field))
arcpy.CalculateField_management(sr, "RValue", esp, "PYTHON3")
print (RValue.getValue(field))


Well, the first print gives a



<geoprocessing cursor object object at 0x0000025F5C161E70>


the second print does isolate all none items, as there is no null in python.



Here is the trick:



the third print either gives error or turn everything into null or 0,focus on everything, expressions I use are as follows:



esp="!RValue!.replace(None, 0)"

esp2="!RValue! * 0"

esp3="set field = 0 where field is null"

esp4="NVL(RValue,0)"

esp5="select nvl(RValue, 0) from sr.RValue"

esp6="None"


How is that even possible when the if before it already isolate only those nones?



I got a warning of



Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique.


I'm very new to this form.So please forgive some beginner's fault.From what I saw it did bear some similarity to mine. But I do think the answers in mine is better.
If you have to join my question into his, please keep those answers.







arcpy field-calculator python-parser null






share|improve this question









New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 26 mins ago





















New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









Karl Tian

83




83




New contributor




Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Karl Tian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • also I've tried RValue.setValue(field,0) , also error 99999.
    – Karl Tian
    1 hour ago










  • so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
    – Karl Tian
    1 hour ago










  • Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
    – Andy
    1 hour ago


















  • also I've tried RValue.setValue(field,0) , also error 99999.
    – Karl Tian
    1 hour ago










  • so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
    – Karl Tian
    1 hour ago










  • Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
    – Andy
    1 hour ago
















also I've tried RValue.setValue(field,0) , also error 99999.
– Karl Tian
1 hour ago




also I've tried RValue.setValue(field,0) , also error 99999.
– Karl Tian
1 hour ago












so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
– Karl Tian
1 hour ago




so many ways I've tried, either 99999 or apply to everything, other errors I've fixed.
– Karl Tian
1 hour ago












Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
– Andy
1 hour ago




Possible duplicate of Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?
– Andy
1 hour ago










2 Answers
2






active

oldest

votes


















2














In your second version, you've mixed cursors and CalculateField_management(). They don't work together in this way. CalculateField_management() will change the value for ALL RECORDS*, and pays no attention to what is happening in your cursor.



You should use either an UpdateCursor (NOT a SearchCursor) OR use a CalculateField_management(). Not both.



I usually do this sort of thing with just a CalculateField_management().
You can do this in one of two ways:



OPTION 1:



This is quicker than OPTION 2 below (but I posted 2 first, so will leave it there as is). This method only updates the records that need changing and also requires fewer lines. I think it is somewhat easier to read too.



Firstly, either select just the records that you want to change to '0' OR make a feature layer that only includes those records. I prefer the latter, as I feel safer (in the case the select doesn't work, you'll change ALL records; in the case the new feature layer doesn't work, you'll just get an error).



Then change all selected/layer records.



It's merely two lines:



arcpy.MakeFeatureLayer_management(sr, "srLayer", "RValue IS NULL")
arcpy.CalculateField_management("srLayer", "RValue", "0", "PYTHON")


Although you may like to clean up afterwards by deleting the layer with a third line:



arcpy.Delete_management("srLayer")


OPTION 2:



Include a code block which will determine the correct value for all records. Note that this will update records that don't need to be changed, but it will update them with the same value they already have, so not a big deal.



But this means that it is slower than OPTION 1 and also not as good for auditing purposes (eg, if you use editor tracking!).



codeblock = """
def calcRValue(rvalue):
if rvalue is None:
return 0
else:
return rvalue
"""
arcpy.CalculateField_management(sr, "RValue", "calcRValue(!RValue!)", "PYTHON", codeblock)


OTHER NOTES:



Don't use arcpy.SearchCursor or arcpy.UpdateCursor, which have been superceded. Use arcpy.da.SearchCursor or arcpy.da.UpdateCursor. They are massively faster (even if marginally more difficult syntax).



I'm not sure what your first version is trying to do, but the last line (print) uses the variable RValue out of scope and I would not expect it to work there. Perhaps it should be indented to be within the loop to print the value each time around the loop? But I'm not sure what it's supposed to be doing there.



*actually, all selected records if there are any, or all records otherwise.






share|improve this answer























  • thank you, that just solve my problem
    – Karl Tian
    35 mins ago










  • You're welcome. :-)
    – Son of a Beach
    32 mins ago





















1














I prefer to use an UpdateCursor to manipulate feature class attributes. However, make sure to use the modern Data Access da cursors. For example:



import arcpy

fc = r'C:pathtoyourgeodatabase.gdbfeatureclass'

with arcpy.da.UpdateCursor(fc, "some_field") as cursor:
for row in cursor:
if row[0] == None: # None appears as <Null> in attribute table float fields
row[0] = 0
cursor.updateRow(row)





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Karl Tian is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f307543%2fconverting-none-to-zero-0-in-geodatabase-table-using-arcpy%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    In your second version, you've mixed cursors and CalculateField_management(). They don't work together in this way. CalculateField_management() will change the value for ALL RECORDS*, and pays no attention to what is happening in your cursor.



    You should use either an UpdateCursor (NOT a SearchCursor) OR use a CalculateField_management(). Not both.



    I usually do this sort of thing with just a CalculateField_management().
    You can do this in one of two ways:



    OPTION 1:



    This is quicker than OPTION 2 below (but I posted 2 first, so will leave it there as is). This method only updates the records that need changing and also requires fewer lines. I think it is somewhat easier to read too.



    Firstly, either select just the records that you want to change to '0' OR make a feature layer that only includes those records. I prefer the latter, as I feel safer (in the case the select doesn't work, you'll change ALL records; in the case the new feature layer doesn't work, you'll just get an error).



    Then change all selected/layer records.



    It's merely two lines:



    arcpy.MakeFeatureLayer_management(sr, "srLayer", "RValue IS NULL")
    arcpy.CalculateField_management("srLayer", "RValue", "0", "PYTHON")


    Although you may like to clean up afterwards by deleting the layer with a third line:



    arcpy.Delete_management("srLayer")


    OPTION 2:



    Include a code block which will determine the correct value for all records. Note that this will update records that don't need to be changed, but it will update them with the same value they already have, so not a big deal.



    But this means that it is slower than OPTION 1 and also not as good for auditing purposes (eg, if you use editor tracking!).



    codeblock = """
    def calcRValue(rvalue):
    if rvalue is None:
    return 0
    else:
    return rvalue
    """
    arcpy.CalculateField_management(sr, "RValue", "calcRValue(!RValue!)", "PYTHON", codeblock)


    OTHER NOTES:



    Don't use arcpy.SearchCursor or arcpy.UpdateCursor, which have been superceded. Use arcpy.da.SearchCursor or arcpy.da.UpdateCursor. They are massively faster (even if marginally more difficult syntax).



    I'm not sure what your first version is trying to do, but the last line (print) uses the variable RValue out of scope and I would not expect it to work there. Perhaps it should be indented to be within the loop to print the value each time around the loop? But I'm not sure what it's supposed to be doing there.



    *actually, all selected records if there are any, or all records otherwise.






    share|improve this answer























    • thank you, that just solve my problem
      – Karl Tian
      35 mins ago










    • You're welcome. :-)
      – Son of a Beach
      32 mins ago


















    2














    In your second version, you've mixed cursors and CalculateField_management(). They don't work together in this way. CalculateField_management() will change the value for ALL RECORDS*, and pays no attention to what is happening in your cursor.



    You should use either an UpdateCursor (NOT a SearchCursor) OR use a CalculateField_management(). Not both.



    I usually do this sort of thing with just a CalculateField_management().
    You can do this in one of two ways:



    OPTION 1:



    This is quicker than OPTION 2 below (but I posted 2 first, so will leave it there as is). This method only updates the records that need changing and also requires fewer lines. I think it is somewhat easier to read too.



    Firstly, either select just the records that you want to change to '0' OR make a feature layer that only includes those records. I prefer the latter, as I feel safer (in the case the select doesn't work, you'll change ALL records; in the case the new feature layer doesn't work, you'll just get an error).



    Then change all selected/layer records.



    It's merely two lines:



    arcpy.MakeFeatureLayer_management(sr, "srLayer", "RValue IS NULL")
    arcpy.CalculateField_management("srLayer", "RValue", "0", "PYTHON")


    Although you may like to clean up afterwards by deleting the layer with a third line:



    arcpy.Delete_management("srLayer")


    OPTION 2:



    Include a code block which will determine the correct value for all records. Note that this will update records that don't need to be changed, but it will update them with the same value they already have, so not a big deal.



    But this means that it is slower than OPTION 1 and also not as good for auditing purposes (eg, if you use editor tracking!).



    codeblock = """
    def calcRValue(rvalue):
    if rvalue is None:
    return 0
    else:
    return rvalue
    """
    arcpy.CalculateField_management(sr, "RValue", "calcRValue(!RValue!)", "PYTHON", codeblock)


    OTHER NOTES:



    Don't use arcpy.SearchCursor or arcpy.UpdateCursor, which have been superceded. Use arcpy.da.SearchCursor or arcpy.da.UpdateCursor. They are massively faster (even if marginally more difficult syntax).



    I'm not sure what your first version is trying to do, but the last line (print) uses the variable RValue out of scope and I would not expect it to work there. Perhaps it should be indented to be within the loop to print the value each time around the loop? But I'm not sure what it's supposed to be doing there.



    *actually, all selected records if there are any, or all records otherwise.






    share|improve this answer























    • thank you, that just solve my problem
      – Karl Tian
      35 mins ago










    • You're welcome. :-)
      – Son of a Beach
      32 mins ago
















    2












    2








    2






    In your second version, you've mixed cursors and CalculateField_management(). They don't work together in this way. CalculateField_management() will change the value for ALL RECORDS*, and pays no attention to what is happening in your cursor.



    You should use either an UpdateCursor (NOT a SearchCursor) OR use a CalculateField_management(). Not both.



    I usually do this sort of thing with just a CalculateField_management().
    You can do this in one of two ways:



    OPTION 1:



    This is quicker than OPTION 2 below (but I posted 2 first, so will leave it there as is). This method only updates the records that need changing and also requires fewer lines. I think it is somewhat easier to read too.



    Firstly, either select just the records that you want to change to '0' OR make a feature layer that only includes those records. I prefer the latter, as I feel safer (in the case the select doesn't work, you'll change ALL records; in the case the new feature layer doesn't work, you'll just get an error).



    Then change all selected/layer records.



    It's merely two lines:



    arcpy.MakeFeatureLayer_management(sr, "srLayer", "RValue IS NULL")
    arcpy.CalculateField_management("srLayer", "RValue", "0", "PYTHON")


    Although you may like to clean up afterwards by deleting the layer with a third line:



    arcpy.Delete_management("srLayer")


    OPTION 2:



    Include a code block which will determine the correct value for all records. Note that this will update records that don't need to be changed, but it will update them with the same value they already have, so not a big deal.



    But this means that it is slower than OPTION 1 and also not as good for auditing purposes (eg, if you use editor tracking!).



    codeblock = """
    def calcRValue(rvalue):
    if rvalue is None:
    return 0
    else:
    return rvalue
    """
    arcpy.CalculateField_management(sr, "RValue", "calcRValue(!RValue!)", "PYTHON", codeblock)


    OTHER NOTES:



    Don't use arcpy.SearchCursor or arcpy.UpdateCursor, which have been superceded. Use arcpy.da.SearchCursor or arcpy.da.UpdateCursor. They are massively faster (even if marginally more difficult syntax).



    I'm not sure what your first version is trying to do, but the last line (print) uses the variable RValue out of scope and I would not expect it to work there. Perhaps it should be indented to be within the loop to print the value each time around the loop? But I'm not sure what it's supposed to be doing there.



    *actually, all selected records if there are any, or all records otherwise.






    share|improve this answer














    In your second version, you've mixed cursors and CalculateField_management(). They don't work together in this way. CalculateField_management() will change the value for ALL RECORDS*, and pays no attention to what is happening in your cursor.



    You should use either an UpdateCursor (NOT a SearchCursor) OR use a CalculateField_management(). Not both.



    I usually do this sort of thing with just a CalculateField_management().
    You can do this in one of two ways:



    OPTION 1:



    This is quicker than OPTION 2 below (but I posted 2 first, so will leave it there as is). This method only updates the records that need changing and also requires fewer lines. I think it is somewhat easier to read too.



    Firstly, either select just the records that you want to change to '0' OR make a feature layer that only includes those records. I prefer the latter, as I feel safer (in the case the select doesn't work, you'll change ALL records; in the case the new feature layer doesn't work, you'll just get an error).



    Then change all selected/layer records.



    It's merely two lines:



    arcpy.MakeFeatureLayer_management(sr, "srLayer", "RValue IS NULL")
    arcpy.CalculateField_management("srLayer", "RValue", "0", "PYTHON")


    Although you may like to clean up afterwards by deleting the layer with a third line:



    arcpy.Delete_management("srLayer")


    OPTION 2:



    Include a code block which will determine the correct value for all records. Note that this will update records that don't need to be changed, but it will update them with the same value they already have, so not a big deal.



    But this means that it is slower than OPTION 1 and also not as good for auditing purposes (eg, if you use editor tracking!).



    codeblock = """
    def calcRValue(rvalue):
    if rvalue is None:
    return 0
    else:
    return rvalue
    """
    arcpy.CalculateField_management(sr, "RValue", "calcRValue(!RValue!)", "PYTHON", codeblock)


    OTHER NOTES:



    Don't use arcpy.SearchCursor or arcpy.UpdateCursor, which have been superceded. Use arcpy.da.SearchCursor or arcpy.da.UpdateCursor. They are massively faster (even if marginally more difficult syntax).



    I'm not sure what your first version is trying to do, but the last line (print) uses the variable RValue out of scope and I would not expect it to work there. Perhaps it should be indented to be within the loop to print the value each time around the loop? But I'm not sure what it's supposed to be doing there.



    *actually, all selected records if there are any, or all records otherwise.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 44 mins ago

























    answered 1 hour ago









    Son of a Beach

    1,383618




    1,383618












    • thank you, that just solve my problem
      – Karl Tian
      35 mins ago










    • You're welcome. :-)
      – Son of a Beach
      32 mins ago




















    • thank you, that just solve my problem
      – Karl Tian
      35 mins ago










    • You're welcome. :-)
      – Son of a Beach
      32 mins ago


















    thank you, that just solve my problem
    – Karl Tian
    35 mins ago




    thank you, that just solve my problem
    – Karl Tian
    35 mins ago












    You're welcome. :-)
    – Son of a Beach
    32 mins ago






    You're welcome. :-)
    – Son of a Beach
    32 mins ago















    1














    I prefer to use an UpdateCursor to manipulate feature class attributes. However, make sure to use the modern Data Access da cursors. For example:



    import arcpy

    fc = r'C:pathtoyourgeodatabase.gdbfeatureclass'

    with arcpy.da.UpdateCursor(fc, "some_field") as cursor:
    for row in cursor:
    if row[0] == None: # None appears as <Null> in attribute table float fields
    row[0] = 0
    cursor.updateRow(row)





    share|improve this answer


























      1














      I prefer to use an UpdateCursor to manipulate feature class attributes. However, make sure to use the modern Data Access da cursors. For example:



      import arcpy

      fc = r'C:pathtoyourgeodatabase.gdbfeatureclass'

      with arcpy.da.UpdateCursor(fc, "some_field") as cursor:
      for row in cursor:
      if row[0] == None: # None appears as <Null> in attribute table float fields
      row[0] = 0
      cursor.updateRow(row)





      share|improve this answer
























        1












        1








        1






        I prefer to use an UpdateCursor to manipulate feature class attributes. However, make sure to use the modern Data Access da cursors. For example:



        import arcpy

        fc = r'C:pathtoyourgeodatabase.gdbfeatureclass'

        with arcpy.da.UpdateCursor(fc, "some_field") as cursor:
        for row in cursor:
        if row[0] == None: # None appears as <Null> in attribute table float fields
        row[0] = 0
        cursor.updateRow(row)





        share|improve this answer












        I prefer to use an UpdateCursor to manipulate feature class attributes. However, make sure to use the modern Data Access da cursors. For example:



        import arcpy

        fc = r'C:pathtoyourgeodatabase.gdbfeatureclass'

        with arcpy.da.UpdateCursor(fc, "some_field") as cursor:
        for row in cursor:
        if row[0] == None: # None appears as <Null> in attribute table float fields
        row[0] = 0
        cursor.updateRow(row)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 37 mins ago









        Aaron

        37.6k19107247




        37.6k19107247






















            Karl Tian is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Karl Tian is a new contributor. Be nice, and check out our Code of Conduct.













            Karl Tian is a new contributor. Be nice, and check out our Code of Conduct.












            Karl Tian is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f307543%2fconverting-none-to-zero-0-in-geodatabase-table-using-arcpy%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Eastern Orthodox Church

            Zagreb

            Understanding the information contained in the Deep Space Network XML data?