Select to view content in your preferred language

Does having "Null" spelled out serve a function?

1726
8
Jump to solution
08-22-2022 10:00 AM
MattCotterill
Regular Contributor

I'm comparing two versions of a feature class one of which has <Null> spelled out in blank fields and the other just has blanks. Because of this difference, when I run the Detect Feature Changes tool, every feature shows up as having (at minimum) an attribute change. I want to want to run some python code to change either all <Null> to (blank) or vice versa so I can tell which features have been significantly changed. Is there an advantage to one or the other?

Thanks,
Matt

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

A "blank" cell could be truly an empty string, or it could contain one space or more than one space or any of the non-printable utf characters.  looking at the field wouldn't reveal what is what.

Also, numeric can't be represented by any nodata value, except for floats/decimal where there is NaN (not a number, but sadly, there isn't one for integers.

Spreadsheets have brought this empty cell evil to the world of GIS <NULL> is a good clue that the cell is not occupied.


... sort of retired...

View solution in original post

8 Replies
DanPatterson
MVP Esteemed Contributor

A "blank" cell could be truly an empty string, or it could contain one space or more than one space or any of the non-printable utf characters.  looking at the field wouldn't reveal what is what.

Also, numeric can't be represented by any nodata value, except for floats/decimal where there is NaN (not a number, but sadly, there isn't one for integers.

Spreadsheets have brought this empty cell evil to the world of GIS <NULL> is a good clue that the cell is not occupied.


... sort of retired...
MattCotterill
Regular Contributor

Thanks, Dan!

It sounds like I should replace blank cells with <Null>. I noticed when I typed in <Null> in the title of this post, it would not show up until I changed the text to "Null". If I use the code below, will I run into problems because of the <> symbols?

'<Null>' if !field! is None else !field!‍‍

 

0 Kudos
VinceAngelo
Esri Esteemed Contributor

No, that wouldn't be wise, and it might not work -- What if the string field has a width of 5 or less?

You'd be better off reviewing the non-NULL empty fields for why they have corrupt values, rather than corrupting the valid NULLs.

- V

JoshuaBixby
MVP Esteemed Contributor

Don't do what you are planning on doing!

If you want the field to be NULL for records, then use Python None which is the Python mapping to SQL NULL.  Writing out a text field with the same character representation that ArcGIS shows for SQL NULL will create massive confusion.

MattCotterill
Regular Contributor

Should I instead clear the <Null> values in the other feature class using your code?:

'' if !field! is None else !field!‍‍

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Why do you want to store empty strings instead of NULL?  If there is no data present for a given field and row, NULL is the common marker.  I say marker instead of value because NULL indicates a value is unknown and is not a value in and of itself (this is also why checks for NULL use IS instead of equals).

I think the better approach would be converting fields with either an empty string or only whitespace characters to NULL:

None if !field!.strip() == '' else !field!
MattCotterill
Regular Contributor

I have an original dataset and a copy of the same. In the copy, all the <Null> values became blank, Maybe when it was copied? People have been making edits to both the copy and to the original and I'm trying to reconcile the two. When I run the Detect Feature Changes tool, every feature shows as having an attribute changed and I think that's because of the missing <Null>s. I want all the <Null>s/blanks to look the same so that when I run the tool, only the changes people actually made are detected

0 Kudos
DanPatterson
MVP Esteemed Contributor

And in my previous incarnation... there is this missive

The solution to <null> in tables - Esri Community


... sort of retired...
0 Kudos