Page 1 of 1

getting mixed-up data into tab delimited columns

Posted: Wed Jan 18, 2006 11:01 am
by Robertheron
Hi,

I'm trying to get this to work - any suggestions would be appreciated...

I have used textpipe (pro version) to put a marker in front of certain types of data in a file of 17,000 lines. The marker I have inserted is the number of the column I want that piece of data to end up in. My markers are {001}, {002} ... up to {020}

So I now have a file that looks schematically like this:

{002}b{001}a{004}d{003}c
{004}d{003}c{002}b{001}a
{004}d{001}a{003}c{002}b
{004}d{003}c{002}b
{004}d{001}a{003}c
etc...

What I want is to put everything starting:
{001} in tab column 1
{002} in tab column 2
...
{017} in tab column 17
etc

So the example above would look like this (where > stands for a tab):
a>b>c>d
a>b>c>d
a>b>c>d
>b>c>d
a>>c>d

Note that only data is tagged - null fields are not tagged (e.g. lines 4 and 5 above are each missing one field - most lines in my files contain only a few fields - so I want all the null fields to contain just tabs).

Any suggestions?

Thanks

Robert

Posted: Fri Jan 20, 2006 10:00 am
by DataMystic Support
Hi Robert,

Handle this with a 4 separate search replaces - for {004}, then {003}, then {002} and finally {001}, each moving the field to the start of the line.

e.g. find easy pattern:

Code: Select all

  [ capture( longest 0+ not cr or lf ), '{004}', capture( longest 0+ not '{' or cr or lf ) ]
Replace with:

$2\t$1

and so on for 3 downto 1.