Transform Column

Help with writing and playing macros

Transform Column

Postby Eskimo » Tue Apr 27, 2010 8:25 am

Hi!"
I'm a beginner with UE and i've got only a trial version for testing.

Is it possible to do the following transforming?

header A
data 1a
data 2a
...
header B
data 1b
data 2b
...

transform in:

header A header B ...
data 1a data 1b ...
data 2a data 2b ...
... ... ...

Is it possible?
How does it work?

Thank you for reply!
Eskimo
:?
Eskimo
Newbie
 
Posts: 2
Joined: Tue Apr 27, 2010 7:36 am

Re: Transform Column

Postby pietzcker » Tue Apr 27, 2010 1:50 pm

This is certainly possible. The complexity of the solution (assuming you want a fully automated one) depends on a few factors, though. For instance, is the length of the sections (=number of lines between headers) constant and known in advance?
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Transform Column

Postby Eskimo » Mon May 03, 2010 3:02 am

Thanks!
The length of the sections is constant and known.
How does ist work?
Eskimo
Newbie
 
Posts: 2
Joined: Tue Apr 27, 2010 7:36 am

Re: Transform Column

Postby pietzcker » Mon May 03, 2010 3:58 pm

The most elegant solution would probably be using a script. I'm not a JavaScript guy, so I can't show you how to do that (I prefer Python for this kind of work).

But you could also do it using a macro. The only conditions are:
1. The first header has to be longer than all following lines of the first section, or characters will get mixed. After that, line lengths don't matter. (It's possible to augment the macro so that line lengths don't matter for the first section, but let's not get carried away now :))
2. There has to be an empty line at the end. Otherwise the macro will never stop.

This macro works on an example file where each section including headers is four lines long:

Code: Select all
InsertMode
ColumnModeOff
HexOff
Loop 0
Key Ctrl+HOME
Key DOWN ARROW
Key DOWN ARROW
Key DOWN ARROW
Key DOWN ARROW
IfEof
ExitLoop
EndIf
StartSelect
Key DOWN ARROW
Key DOWN ARROW
Key DOWN ARROW
Key DOWN ARROW
EndSelect
Cut
Key Ctrl+HOME
Key END
" "
ColumnModeOn
Paste
ColumnModeOff
EndLoop


For more lines, add more "Key DOWN ARROW" lines.

This macro will transform

Code: Select all
header A
data 1ad
data 2a
...
header B
datatest 1b
data 2b
...
header C
data 1c
datalonger 2c
...
header D
data 1d
data 2d
...


to

Code: Select all
header A header B    header C      header D
data 1ad datatest 1b data 1c       data 1d
data 2a  data 2b     datalonger 2c data 2d
...      ...         ...           ...     
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm


Return to Macros