field calculator question

2548
7
Jump to solution
07-31-2014 10:03 AM
TavisThomson
New Contributor

when inputting this python script into field calculator Arcmap freezes and crashes:

code block

def my_func(my_field)

    if my_field is None:

         return " "

    while my_field is not None:

          pass

field

My_func(!" "!)

If there is a large amount of dat in this field is there another way to sort more efficiently?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

unfortunately not, a space isn't the same as null.   Also see the help file on using code blocks  ArcGIS Help (10.2, 10.2.1, and 10.2.2)

View solution in original post

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

do you have a field name with just a space in its name (! !)?

0 Kudos
TavisThomson
New Contributor

Most of the time the fields that I am trying to run this script on are date fields that are set up in the format of

%m-%d-%y. The issue I keep facing is having to go through the selection and find all null values, then calculate them after that. I was just hoping that this could be a way to semi automate that process.

0 Kudos
DanPatterson_Retired
MVP Emeritus

unfortunately not, a space isn't the same as null.   Also see the help file on using code blocks  ArcGIS Help (10.2, 10.2.1, and 10.2.2)

0 Kudos
TavisThomson
New Contributor

The field name that I run this code on is DATE_ and for (my_field) inside of the function  is what I use as a field for running the script. The field name isn't a space it comes out as this in the box below the pre script logic:

DATE_=

my_func(!DATE_!)

0 Kudos
DanPatterson_Retired
MVP Emeritus

It was the my_func(" ") in your original post that was confusing

TavisThomson
New Contributor

Haha Sorry! Thanks for that link, I found something in there that might make it all better.

0 Kudos
RhettZufelt
MVP Frequent Contributor

If there is a large amount of dat in this field is there another way to sort more efficiently?

What about select by attributes Date_ IS NULL?

Then calculate field = " "

R_

0 Kudos