Skip to main content
Question

How to extract all unique combinations?

  • November 11, 2020
  • 4 replies
  • 57 views

I'm trying to extract all unique combinations of a given datamodel. 

 

For example:

Table 1.

FRUIT	COLOR	TYPE
Apple	Green	Kanzi
	Yellow	Jonagold
	Red	Elstar
	Golden	Fuji
	Pink	Golden Delicious
		Royal Gala

With this given datamodel, I can make 30 unique combinations.

Like this:

Table 2.

FRUIT	COLOR	TYPE
Apple	Green	Kanzi
Apple	Green	Jonagold
Apple	Green	Elstar
Apple	Green	Fuji
Apple	Green	Golden Delicious
Apple	Green	Royal Gala
Apple	Yellow	Kanzi
Apple	Yellow	Jonagold
Apple	Yellow	Elstar
Apple	Yellow	Fuji
Apple	Yellow	Golden Delicious
Apple	Yellow	Royal Gala
Apple	Red	Kanzi
Apple	Red	Jonagold
Apple	Red	Elstar
Apple	Red	Fuji
Apple	Red	Golden Delicious
Apple	Red	Royal Gala
Apple	Golden	Kanzi
Apple	Golden	Jonagold
Apple	Golden	Elstar
Apple	Golden	Fuji
Apple	Golden	Golden Delicious
Apple	Golden	Royal Gala
Apple	Pink	Kanzi
Apple	Pink	Jonagold
Apple	Pink	Elstar
Apple	Pink	Fuji
Apple	Pink	Golden Delicious
Apple	Pink	Royal Gala

I made table 2 in excel with copy and pasting. The real dataset that I have has alot more columns and values. Therefore I would like to automate this proces in FME.

 

How can I transform table 1 to table 2?

4 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 11, 2020

Whilst it's probably possible to do this in FME with your example, I'm not sure it would scale up very well. You might be able to do something with the inline querier, itertools in a pythoncaller is probably the way to go though


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 11, 2020

A simple example based on your sample input

 Capture


  • Author
  • November 12, 2020
ebygomm wrote:

A simple example based on your sample input

 Capture

Amazing, will try this out! Thanks alot!


Forum|alt.badge.img+2
  • November 12, 2020

@wereldbol​  if, like me, you're not a strong python developer, you should be able to accomplish thi with a couple of FeatureJoiners. Not nearly as elegant or flexible as @ebygomm​ 's python.


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