How to merge two or more columns into a single one

Even though Tabulizer does not have any built-in functionality for merging the data of two or more cells, this can be easily achieved by using a modification function. In this tutorial we will present a way of doing that by using the columnmerge modification function.

OK, let's start with our initial sample table:

Name Age

Let's assume that we want to merge columns 1 and 2, so instead of displaying first and last name on separate columns we will combine these two columns into a single one that will show the full name (first + last name). We also want to add a space between the two combined columns, otherwise Mary Jane would be MaryJane and so on.

Therefore the merging argument becomes the following:

1+" "+2=2
What this means is merge column #1, an empty space and column #2 and put the combined value into column #2. Generally speaking, the merging argument has the following format:
column id + ... + "string value" + .... = assigned column id
Apparently you cannot have double quotes inside a string value (as they are used for escaping the string value), but instead you should use the " notation. You can combine as many columns and string values as you wish. The assigned column id is the column that will receive the combined value, and it can in the merging input list as well.

After adding a table rule calling the columnmerge modification function with the merging argument em>1+" "+2=2 the result is the table below:

NameName Age
MaryMary Jane23
JamesJames Johnson34
JelenaJelena Maric49
PaulPaul Geston19

and here is the rule settings we used:

It looks good, but there is still one thing we need to do: to remove the first column that now it's redundant. This can be easily achived by adding a new column rule that will remove the first column.

The end result is the table below:

Name Age
Mary Jane23
James Johnson34
Jelena Maric49
Paul Geston19

Important! The order of execution does make a difference in this case, so the rule the merges the column should be executed before the rule that removes the first column. The order of execution is usually the same as the order of rule definition, at least for rules that belong to the same group, but if you want to be certain you can use the priority field as we did in this example to explicitly the the order of execution.
You can download the columnmerge modification along with the demo ruleset by clicking here. When you import the ruleset check the YES, overwrite safemode settings.. Also, make sure you are using Tabulizer version 5.2.11 or newer.