getting mixed-up data into tab delimited columns

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
Robertheron
Posts: 1
Joined: Wed Jan 18, 2006 9:15 am
Location: Australia

getting mixed-up data into tab delimited columns

Post 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
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post 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.
Post Reply