About EasyMorph Tutorials & Examples Web-help

Add date every two columns


#1

Hi everyone !! I’m new in EasyMorph and so far I like it a lot !!

But I have one file that i want to process wich dont have the header of the Date, its something like this :

Camara | Laboratorio | Etico | Popular | Etico | Popular | Etico | Popular | Etico | Popular | Etico | Popular | Etico | Popular | Etico | Popular | Etico | Popular

Every two columns correspond to one month, so I have to transform that file in something like this :

Camera | Laboratorio | Jan 17 | Jan 17 | Feb 17 | Feb 17 | ... etc
XXXXX | XXXXXXXX     | Etico  | Popular| Etico  | Popular| .... etc

Is there any way to do this ??


#2

Welcome to the Community, Axel!

I would do it this way:

  1. Split the original table into two tables – the 1st row (with headers) and the rest of rows.
  2. Unpivot the table with headers and calculate lower and upper headers as columns.
  3. Pivot the lower and upper headers back so that each of them is a new row.
  4. Assemble the headers and the rest of rows back into one table.

Assembling back has a tricky moment, as unpivoting and pivoting changes the order of columns. Therefore, I created an empty table that preserves the original order of columns and used it as a master table for appending other tables.

Here is a project that does it:

matrix headers.morph (13.2 KB)
data.txt (271 Bytes)