Skip to main content
Question

Populate entire column based on specific value in the same column


Is there an easy way to populate an entire column (I have multiple columns) based on the value in that column that has a comma in it?

Basically, if I have a column named pole and all attributes in that column have the value of "pole_status" except for one value that has this value: "Con, PLA, MRC, MRE". How can I populate the entire column with "Con, PLA, MRC, MRE".

I've tried Attribute Manager using a Conditional Value to filter out all records that don't have comma in it but then I'm not sure how I can actually use the "Con, PLA, MRC, MRE" value as the output value. Maybe there's a better option. Custom Python might do the trick - but I want to exhaust all of my transformer options before I go that route. Note: I cant simply write "Con, PLA, MRC, MRE" in the AttributeManager since these values will change and there's multiple columns - si it wouldn't be sustainable

I also know I can probably accomplish this by using a multiple FeatureMergers but I definitely don't want to do that (if I dont have to) due to performance (there would probably be 20 + FeatureMergers).

Thanks!

4 replies

lars_de_vries
Forum|alt.badge.img+10

I think that I would use a TestFilter to find a feature that matches "pole" Contains ','. Subsequently I would use a Sampler to make sure only a single feature will be output through a FeatureMerger (or FeatureJoiner in FME2018). I would set the FeatureMarger/-Joiner to match 1 - to - 1 (making it an unconditional merge) and make all features from "pole" pass. You could use a AttributeRemover to remove the "pole" attribute from the supplier features.

I hope this helps you.


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • April 2, 2018

So it sounds like you need to scan all the values for a column in all the rows, and if any of them had a , choose the first one that has the , and use that for as the value. Else leave them as they were. I'd suggest a workflow involving a tester, followed by a VariableSetter when you find the match (i.e. set a global variable named after the column to have the value of the , value). Do this tester/variablesetter for each column you want to do this to. Then route everything to FeatureHolder. After the feature holder use a Variable Retriever to pull out the value for the column and set it (you'll need one for each column). Lastly, you may need to set a default value for each Variable using a Creator followed by VariableSetters if you aren't guaranteed of one row with a ,

 

 

Great scenario. Let us know if this works (and if anyone has a better idea, do share).

fmelizard wrote:

So it sounds like you need to scan all the values for a column in all the rows, and if any of them had a , choose the first one that has the , and use that for as the value. Else leave them as they were. I'd suggest a workflow involving a tester, followed by a VariableSetter when you find the match (i.e. set a global variable named after the column to have the value of the , value). Do this tester/variablesetter for each column you want to do this to. Then route everything to FeatureHolder. After the feature holder use a Variable Retriever to pull out the value for the column and set it (you'll need one for each column). Lastly, you may need to set a default value for each Variable using a Creator followed by VariableSetters if you aren't guaranteed of one row with a ,

 

 

Great scenario. Let us know if this works (and if anyone has a better idea, do share).
@daleatsafe So there's a couple of ways to accomplish this and your solution seems to work faster than mine - at this point in my workflow (it's a huge workflow) I just wanted to optimize this part. Good enough thanks!

 


lars_de_vries wrote:

I think that I would use a TestFilter to find a feature that matches "pole" Contains ','. Subsequently I would use a Sampler to make sure only a single feature will be output through a FeatureMerger (or FeatureJoiner in FME2018). I would set the FeatureMarger/-Joiner to match 1 - to - 1 (making it an unconditional merge) and make all features from "pole" pass. You could use a AttributeRemover to remove the "pole" attribute from the supplier features.

I hope this helps you.

 

@lars_de_vries this works well but looks like Dale's solution was a bit faster - faster than mine as well

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