Skip to main content

I have an an attribute in my table that is type 'string', and I am trying to work out how to associate a code to each of these different attribute types so this code can be used in the next transformer.

 

See screenshot, for example I have added red text, so for POTHOLES, I need to feed the integer 70 into my HTTP caller, for SEAL OVERLAY I need to use the code 105 in my HTTP caller and so on...

 

I am unsure how to set these codes for each of my unique values.

 

I was about to create a new HTTP caller for each of my different attributes and hard code the variable, but I know that would be a terrible idea as I should be able to code this better.

 

Have I explained this well enough to understand? I'm having a hard time describing it!

 

Attribute Filter into HTTP Caller

Multiple ways to do this but the official way is probably the AttributeValueMapper. Very straight forward, if POTHOLES then 70, if SEAL OVERLAY then 105, etc.

 

Personally, I prefer using an Excel file and a FeatureMerger to merge the codes to the data, because creating the mapping in Excel is often more intuitive and faster. Also depends on how much mappings you have. Attached workspace demonstrating both methods.

 

I also see you renamed the HTTPCaller to "Create_Action". It is my best practice to not rename transformers but to add annotations. This makes reviewing / editing your workspace easier because one does not have to open the transformer to see what it is.


Multiple ways to do this but the official way is probably the AttributeValueMapper. Very straight forward, if POTHOLES then 70, if SEAL OVERLAY then 105, etc.

 

Personally, I prefer using an Excel file and a FeatureMerger to merge the codes to the data, because creating the mapping in Excel is often more intuitive and faster. Also depends on how much mappings you have. Attached workspace demonstrating both methods.

 

I also see you renamed the HTTPCaller to "Create_Action". It is my best practice to not rename transformers but to add annotations. This makes reviewing / editing your workspace easier because one does not have to open the transformer to see what it is.

Fantastic, I knew there would be a transformer, I had no idea what it would be called! Thank you for the tips too!


Multiple ways to do this but the official way is probably the AttributeValueMapper. Very straight forward, if POTHOLES then 70, if SEAL OVERLAY then 105, etc.

 

Personally, I prefer using an Excel file and a FeatureMerger to merge the codes to the data, because creating the mapping in Excel is often more intuitive and faster. Also depends on how much mappings you have. Attached workspace demonstrating both methods.

 

I also see you renamed the HTTPCaller to "Create_Action". It is my best practice to not rename transformers but to add annotations. This makes reviewing / editing your workspace easier because one does not have to open the transformer to see what it is.

I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 


I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 

I think it can not. This is one of the reasons why the external lookup file is my preferred way to go. 

Just use a Sampler (group by Type, set to 1st N) to generate a unique list of types, add to Excel, add codes, FeatureReader, FeatureMerger. It is just less time consuming.


I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 

You can't do that in the AttributeValueMapper, you'll have to resort to conditional values inside an AttributeCreator or AttributeManager.

 

I'm trying to get my head around the idea of using conditional values in the source column of an AttributeValueMapper and my mind is boggling. I don't think it's going to work that way (but would be happy to be proven wrong on this one). @mark2atsafe​ wondering what you think.


I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 

I tried this out (described it during my question of the week video, here: https://www.youtube.com/watch?v=QB3LXE9ycp0&t=1505s - and I really don't know if it's possible. Like you, I'm struggling to get my head around it. I think you could use conditional values like this, but it's not going to work for this scenario.


I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 

Not a wildcard, but you could use a SubstringExtractor to get the first 10 (for example) characters of the string. Then you use that as the left-hand value (so HEAVY PATC). That's similar to using a wildcard, because everything after the 10th character isn't used.


I am wondering if you know if there is a way to use a 'wildcard' in the mapper?

 

See the below screenshot, I have several 'heavy patching' attributes, but they all need to be mapped to 53, instead of mapping each heavy patching individually, can I do something like "Heavy Patching*" etc?

 

2022-04-01 16_20_19-Window 

Just FYI the conditionals keep erroring out for some reason:

|ERROR |AttributeValueMapper: Invalid Test Expression: CASE_INSENSITIVE_TEST<at>Value<openparen>Works<closeparen>BEGINS_WITHHEAVY

 

 

2022-04-01 16_36_02-Window 

@mark2atsafe​  I appreciate you explaining your thoughts on your YouTube video, it helped me understand greatly why what I was trying to do, wouldn't work in this instance. I am glad it made your mind boggle also :D

I am all operational with the scenario suggested by @nielsgerrits​ in the first post. 

Than you all for your time, its appreciated! 😎 


Reply