Field Calculator: Text White Space Bug - Pro 2.5.1

1379
7
05-13-2020 02:27 PM
RomaHicks
New Contributor II

I am working on trying to get a dataset that was lazily collected and processed by a contractor, fixed. There are values in the fields that have lot of leading, trailing whitespace and in some cases both leading and trailing whitespace.  At time more than one whitespace.

  • I would expect: the Insert Values control in the Field Calculator to show all unique values found in the field.
  • What actually happens: the Insert Value control ignores all whitespaces and incorrectly identifies different values as a single value

The values:

  • "Yes"
  • " Yes"
  • "Yes "
  • "Yes  "

Are all different values and should be treated as such.

I wanted to report a bug but the support page claims I don't belong to a organisation, which I do. And I shouldn't need a support case to report a bug, I don't need someone to fawn over me, it just needs better programming, unit testing and fixed.

Tags (2)
0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

To be on the safe side, add a new text field and use the field calculator expression (python, replace the field name)

!YourField!.strip()

# ----- demo
test = [" Yes", " Yes", "Yes     "]

for i in test:
    print("'{}'".format(i.strip()))
    
'Yes'
'Yes'
'Yes'

If you like the result, copy the field back into the original.

If you live on the edge, skip the adding new field and set the undo calculation option


... sort of retired...
0 Kudos
RomaHicks
New Contributor II

Yeah, I have been using regex with the Field Calculator to clean up the whitespace. But I would like to just pick the field and click to check that it is clean. Not run it on every field to make sure it is clean. I am not familiar enough with the API to write a script to just blanket remove all whitespace (and that could be dangerous too), or have enough time to familiarize myself with it right now.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I wanted to report a bug but the support page claims I don't belong to a organisation, which I do.

Regardless of whether you do or don't belong to an organization, Esri's systems aren't attaching you to an organization in the way necessary to open a Support case.  In many organizations, there are a limited number of users that can open cases with Esri Support, and other employees need to work through those "authorized callers."

And I shouldn't need a support case to report a bug

Unfortunately, Esri gets to make those decisions since they developed the software and provide support for it.  You can submit an ArcGIS Ideas‌ to support reporting a bug without opening a Support case, but I doubt Esri will go down that path.  I fought a similar battle with Esri for years, i.e., advocating for a different way of logging defects, but nothing changed.  Eventually, I stopped pushing/advocating because it wasn't going anywhere.

RomaHicks
New Contributor II

Hmm, I am the owner/admin of my organization and I checked when I attempted to report it, but it was transitioned to me and maybe I keep missing it.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Given what you are experiencing, have you tried getting Support on the phone?  It seems something isn't right with the system, and it might take less time to sort out with a person.

0 Kudos
KoryKramer
Esri Community Moderator

It looks like this was submitted recently BUG-000129213: In ArcGIS Pro, the trailing space in the Field attri.. 

(it doesn't appear to be specific to Pro; i.e. ArcMap is not a workaround).

Roma, you could visit that page and click Subscribe.  That will set you up for notifications and also increment the count of affected customers.

Thank you.

0 Kudos
KoryKramer
Esri Community Moderator

Not totally like Calculate Field, but Find and Replace looks like it will work if you set it to 'Match whole field'

Now, you don't know how many other combinations of " Yes", "Yes  ", "  Yes    " etc. exist, but if know what you do want: "Yes" (no spaces) then Find those first and select them.

Then Switch selection, and you'll get the Yes's with spaces.  

Granted, I'm sure the table has some No's or other values, so you may need to try a def query before this, or simply use Dan's script example.  Just thinking through some other options here...

0 Kudos