Skip to main content
Question

Conditional Attribute using derived output value

  • November 10, 2017
  • 4 replies
  • 73 views

sussexpete
Contributor
Forum|alt.badge.img+4

I want to extract a UK postcode from a free-format address field, but only if there is one.

I am using the AttributeManager transformer with a new output attribute value:

 

@Substring(@Value(OriginalAddress),@FindRegEx(@Value(OriginalAddress),"[A-Z][A-Z][0-9][0-9] [0-9][A-Z][A-Z]"),8)

This works but I am getting unwanted results where a UK postcode is not found.

An important point is that OriginalAddress is a derived output attribute: @UpperCase(@Value(OccAddress1) @Value(OccAddress2) @Value(OccAddress3) @Value(OccAddress4) @Value(OccAddress5))I would like to say something on the lines of: If there's a postcode then get postcode else don't bother.Is this possible without resorting to using a python transformer? Trying to set a Conditional Value in AttrubuteManager does not work in this case as only the original input attributes are recognised in the Output Values builder of the Test Conditions (that is, it's only seeing the OccAddressN fields).

 

4 replies

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • November 10, 2017

A string searcher can have an input created from several attributes, and would correctly handle cases where no match was found

Unfortunately, the regex for a UK postcode is a lot more complex than you might first think. Your current regex wouldn't pick up a lot of postcodes


sussexpete
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • November 10, 2017

Thanks @egomm.

I'm trying to reduce the number of transformers in my ever-growing workspace and am a big fan of the AttributeManager which keeps things tidy. Maybe not such a great idea but I'd like to know for sure.

Yes, thanks, I realise the regex is a bit lightweight but it does for codes in the data from my district that I'm processing.

I use the 1Spatial UKPostcodeValidator custom transformer for grown-up stuff. It's really good.

Thanks again.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • November 10, 2017
sussexpete wrote:

Thanks @egomm.

I'm trying to reduce the number of transformers in my ever-growing workspace and am a big fan of the AttributeManager which keeps things tidy. Maybe not such a great idea but I'd like to know for sure.

Yes, thanks, I realise the regex is a bit lightweight but it does for codes in the data from my district that I'm processing.

I use the 1Spatial UKPostcodeValidator custom transformer for grown-up stuff. It's really good.

Thanks again.

Why not just reference the original attributes in your conditional formula if you want to keep everything in the attribute manager? Although it's not easy to decode it should work

 

 

 

 


sussexpete
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • November 10, 2017
sussexpete wrote:

Thanks @egomm.

I'm trying to reduce the number of transformers in my ever-growing workspace and am a big fan of the AttributeManager which keeps things tidy. Maybe not such a great idea but I'd like to know for sure.

Yes, thanks, I realise the regex is a bit lightweight but it does for codes in the data from my district that I'm processing.

I use the 1Spatial UKPostcodeValidator custom transformer for grown-up stuff. It's really good.

Thanks again.

That's a good idea @egomm. Not as elegant, but if it works I'm happy. I'll try it.

 


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