Skip to main content
Solved

Merging collumns while preserving data in other collumns

  • February 25, 2019
  • 8 replies
  • 244 views

bkgg
Contributor
Forum|alt.badge.img+4
  • Contributor

This is my first question so do tell me if I'm missing anything in the description of the question.

 

I currently have a workspace where part of the functionality includes the merging of 5 columns (two of which are always empty). The data that isn't merged should be preserved for each of the rows that are created or already in existence.

 

Below is an Excel example of what I mean:

This is the current situation

 

This is what it needs to become

 

As you can see the data from the first three columns are merged into one but the other three columns (ID, Type and Type 2) remain unchanged and are copied to the new rows.

 

This causes for example the row with ID 500 to split into three rows, all of which contain all attribute information from the original that wasn't merged.

 

I looked for similar questions but the solutions didn't work for me such as the Attribute Exploder, which does not currently have an option to select what you want to explode.

 

The solution given in this question came close but did not give me the correct amount of rows: https://knowledge.safe.com/questions/68241/merge-values-of-two-columns.html

The expected amount of rows is 409 (from the original 213) but after running it I only got 255 rows from this method.

 

The Attribute Pivoter was something I also tried but had no success in. Perhaps this will solve it but I just can't get it to work in the manner that I want it to.

 

Any ideas are welcome.

Best answer by ebygomm

Create an attribute containing the 3 merged values as comma separated values (you'll need a conditional formula to handle that they're not always populated), an attribute splitter to split on the comma then a list exploder.

You could also use the renaming approach you mentioned, but after renaming you will need to test that the attribute has a value since you have blanks in your merged columns e.g.

View original
Did this help you find an answer to your question?

8 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • February 25, 2019

Create an attribute containing the 3 merged values as comma separated values (you'll need a conditional formula to handle that they're not always populated), an attribute splitter to split on the comma then a list exploder.

You could also use the renaming approach you mentioned, but after renaming you will need to test that the attribute has a value since you have blanks in your merged columns e.g.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • February 25, 2019

you can list_concatenate the 3 columns by row_id.

Then explode list.

FeatureMerge with the other columns on key= row_id. Process duplicates and explode.

Sort.


arnovananrooij
Contributor
Forum|alt.badge.img+5

I would use a stringconcatenator to concatenate the three strings that need to be merged. Then use a AttributeSplitter with Drop Empty Parts = Yes to create a list called Merged. The last step is to Explode this list with the ListExploder.


bkgg
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2019
ebygomm wrote:

Create an attribute containing the 3 merged values as comma separated values (you'll need a conditional formula to handle that they're not always populated), an attribute splitter to split on the comma then a list exploder.

You could also use the renaming approach you mentioned, but after renaming you will need to test that the attribute has a value since you have blanks in your merged columns e.g.

So far this has come the closest to solving it but it's still off by a few features. It probably needs some more tweaking on my end. Thanks.


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • February 26, 2019
bkgg wrote:

So far this has come the closest to solving it but it's still off by a few features. It probably needs some more tweaking on my end. Thanks.

If your input is originally coming from excel the first thing I'd check is whether some of the merge columns have spaces in rather than being blank


bkgg
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 28, 2019
ebygomm wrote:

If your input is originally coming from excel the first thing I'd check is whether some of the merge columns have spaces in rather than being blank

It's coming from a GDB file and I also don't think spaces are being used because all the unused rows are showing up as 'Null' rather than being blank.

 

Off topic, how do I go about reporting small things such as typos? Because I know that for ideas or feature requests there is a section but something as small as a typo probably wouldn't warrent its own topic.


xiaomengatsafe
Safer
Forum|alt.badge.img+3
bkgg wrote:

It's coming from a GDB file and I also don't think spaces are being used because all the unused rows are showing up as 'Null' rather than being blank.

 

Off topic, how do I go about reporting small things such as typos? Because I know that for ideas or feature requests there is a section but something as small as a typo probably wouldn't warrent its own topic.

Hi @bkgg. I'm not the expert, so can't be much help with this particular workflow.

 

Regarding your question on how to report small issues. If it is a small typo you spotted on the website, or in the documentation, I'd suggest Live Chat would be the easiest way. If you don't have access to Live Chat due to time differences, feel free to send in a quick support case, through this form. Thank you so much for helping us make our product better, by reporting problems.

bkgg
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • March 1, 2019
xiaomengatsafe wrote:

Hi @bkgg. I'm not the expert, so can't be much help with this particular workflow.

 

Regarding your question on how to report small issues. If it is a small typo you spotted on the website, or in the documentation, I'd suggest Live Chat would be the easiest way. If you don't have access to Live Chat due to time differences, feel free to send in a quick support case, through this form. Thank you so much for helping us make our product better, by reporting problems.

Thanks. I just finished filling in the form.


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