Skip to main content
Question

Finding and replacing a null value with a blank. Possibly with StringReplacer


scarter
Contributor
Forum|alt.badge.img+9

Hello Forum,

 

I have an attribute in a gpkg dataset containing year values (e.g.: 2016). Where a year is unknown the value is <null>.

 

When this dataset is translated into tab or geojson any values of <null> get shown as -9999. I assume that's how the MapInfo tab translator sees <null> values. But instead of -9999 this I want any <null> value to be blank.

 

With StringReplacer I know I can replace a value such as 2016 with 3016, not that I would want to do that!. But when I type in <null> as the 'Text to replace' and leave 'Replacement text' blank, the output still shows -9999 instead of it being blank.

 

I wonder if there is a special way of specifying <null>. How do I effectively replace <null> value in an integer attribute with blank?

 

I've seen https://community.safe.com/transformers-9/replace-value-with-a-null-1778 but that doesn’t quite cover it.

 

Thanks,

Stuart

10 replies

matthieuv
Contributor
Forum|alt.badge.img+20
  • Contributor
  • September 18, 2024

If the output is shown as -9999 it means that it is at that moment an integer and not really Null anymore. If you want to use the StringReplacer you can replace -9999 with nothing and then connect it to an NullAttributeMapper with the following settings:
 

This makes it very clear what you are doing and which you can elaborate on even more with an annotation.

 

Another option is to use an AttributeManager with for example a conditional statement:
 

Normally one line in there would be enough. I put those two as an example. You can play around with your exact dataset to see what works for you.


scarter
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 25, 2024

Thanks for that, @matthieuv . I’ll look into those options.


scarter
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 25, 2024

HI @matthieuv . I tried option one. I have Creator> featureReader>AttributeManager>StringReplacer>NullAttributeManager>FeatureWriter.

 

The StringReplacer and NullAttributeManager are set up like below, but I’m still seeing the value -9999 in the output tab file.

 

 


matthieuv
Contributor
Forum|alt.badge.img+20
  • Contributor
  • September 25, 2024

@scarter if you click on a row in the right screenshot what is the exact information you see in the Data Information Window for the attribute Construction_year_where_known? If you have FME Form 2024 it will also show the data type besides Property and Value.

 

 


scarter
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 25, 2024

@matthieuv . The right side screenshot is from MapInfo.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • September 25, 2024

As @david_r has answered previously.  Mapinfo TAB does not support NULL values in numeric fields and so FME will by default write -9999 in its place.

Separately, don’t need the StringReplacer, can do all substitutions within the one NullAttributeMapper by using the “Or Attribute Value Is” setting.  In here, can define your own “Null” Value to substitute say -1, instead of letting the TAB Writer change Nulls to -9999.
 

 


matthieuv
Contributor
Forum|alt.badge.img+20
  • Contributor
  • September 25, 2024

What do you see if you select a feature when inspecting the result from the FeatureWriter?


scarter
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 25, 2024

@matthieuv I get this in Inspector. Where the years is null/-9999/empty the values shown is <null> .

 


matthieuv
Contributor
Forum|alt.badge.img+20
  • Contributor
  • September 25, 2024

I think I might have misunderstood your question. 

After you read the gpkg add a AttributeManager with a conditional value for your attribute. Replace the yellow attribute with your own.
So if it is Null it will replace it with a value. Leave that value completly empty and then see what the output will be to Mapinfo.

 


scarter
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 25, 2024

@matthieuv Thanks for that. I’ll give it a go. Thanks for all your help on this. I don’t want to use up any more of your time. So, if still not working after that I’ll raise a case through Support. Fingers crossed it works.


Reply


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