getting mixed-up data into tab delimited columns

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

getting mixed-up data into tab delimited columns

Postby Robertheron » Wed Jan 18, 2006 11:01 am

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: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Fri Jan 20, 2006 10:00 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 4 guests