Skip to main content
Question

Empty string, but still not empty !


harmen_kampinga
Forum|alt.badge.img+2

I have tested some attributes of a Shapefile which are empty, with a StringLenghtCalculator and those empty fields returned a value of 254 characters. That's weird. I have tried to replace those empty values with '0' or with 'EMPTY' using the NullAtributeMapper with all options and with the StringReplacer using this regular expression: [^a-zA-Z\\d\\w,.\\-/\\s/+_\\\\]

 

All with no success.... still the attribute value seems to have 254 characters

 

 

A familiar problem to someone? And maybe there is a solution?

5 replies

harmen_kampinga
Forum|alt.badge.img+2

Of course, I can use the AttributeManager and then for every Attribute having that issue creating a new Attribute with a slightly different name using a condition to set the value, but that's not what I want...

 

 

The condition would like to be:

 

@StringLength(@Value(FIELDNAME)) = 254

 

And in that case, give it a default value.

 

And if it is not 254 characters, then add the value of the 'wrong' Attribute.

 

 

But if there are 254 characters representing a right string or value, then this condition doesn't make sense.

takashi
Influencer
  • July 7, 2019

I guess that the field has been filled with 254 spaces. Try removing all spaces from the attribute value with the AttributeTrimmer.


harmen_kampinga
Forum|alt.badge.img+2
takashi wrote:

I guess that the field has been filled with 254 spaces. Try removing all spaces from the attribute value with the AttributeTrimmer.

Thanks @takashi for your reply, but unfortunately that doesn't work... inspecting the value of the Shapefile doesn't come up with anything. It's empty/empty so to say. But in FME not recognized as a NULL, Missing Value, or whatever so far...


takashi
Influencer
  • July 7, 2019
takashi wrote:

I guess that the field has been filled with 254 spaces. Try removing all spaces from the attribute value with the AttributeTrimmer.

Is the length of the attribute value still 254 after trimming?


Forum|alt.badge.img+2

Hi @harmen1,

I stumbled across this post whilst researching a similar issue and hopefully have some answers for you.

If you use an AttributeEncoder on these attributes and set the Destination Encoding to binary does this return a value of 254 zeros? These represent null bytes, these are not printable which is why in a logger or inspector the attribute value looks like an empty string but, as proved by the StringLengthCalculator in fact it is not - which is why your NullAttributeMapper is not working as expected.

Perhaps you could use the Attribute Encoder Output to fix these - as if they do contain a true value the output will be different so you can use that in your test condition rather than the string length.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings