2

When I'm in an editing session and I manually delete a value from a numeric field the value turns to null (<Null>). Manually deleting a value in a string field creates an empty string, not a Null. Currently I select the record and field calculate Null, which is clunkier. Is there a fast way to change a string to a Null in an attribute table?

  • I think that in the attribute table, if you remove text from a String field, and type <Null> it will actually set the field to NULL. I will check this and post an answer if confirmed – Midavalo Feb 4 at 17:51
  • @Midavalo I can confirm that this method adds the string <Null> and not a null value. – Emil Brundage Feb 4 at 17:58
  • I've just confirmed my suspicion is correct (although not through the attribute table) - see my answer – Midavalo Feb 4 at 18:13
2

This solution works using the Attribute Editor, but does not work through the Attribute Table.

Select the records you want to update to NULL

Open the Attribute Editor from the Editor toolbar

enter image description here

If you have more than one feature you want to update, select the top row (this makes any attributes you edit update all selected records)

enter image description here

In the field you want to update, type <Null>

enter image description here

This will actually set the field to NULL for the selected records, and not to the string value "<Null">. You can confirm this by doing a Select by Attributes textfield is NULL - if they are true NULL they'll be selected.

enter image description here

| improve this answer | |
  • I like this approach as well if you're manually editing lots of rows and cannot automate the process any further. +1 – GISKid Feb 4 at 18:44
1

You could replace any empty strings with another string from the field calculator. Using python, where STATE_NAME is the field:

!STATE_NAME!.replace("", "thisisareplacement")

If you mean Null not as a string you could try using a codeblock:

def replace(x):
  if x =="":
    return None
  else:
    return x

Under field, replace(!STATE_NAME!)

Beyond that you could use if / else statements in your workflow to further automate the process based on your specifications.

You may also be able to do this by setting defaults, but you need to have the data in a geodatabase where NULL values are allowed see here: https://support.esri.com/en/technical-article/000012852

| improve this answer | |
  • In Python, the term for NULL is None. Adding "Null" is adding the text "Null", not setting the contents to NULL. Perhaps !STATE_NAME!.replace("", None) might work better? – Midavalo Feb 4 at 17:45
  • 1
    @Midavalo realized that and edited – GISKid Feb 4 at 17:45
  • great - I think my suggested !STATE_NAME!.replace("", None) won't work either, as you need a string value for replace. Returning None is a better option. +1 – Midavalo Feb 4 at 17:47
  • 1
    This is all more complicated than my current method of selecting the row manually, right-clicking the field and field calculating null. – Emil Brundage Feb 4 at 17:55
  • @EmilBrundage is there specific criteria for what you select manually and what needs to be null? aka could it be automated? – GISKid Feb 4 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.