Replace column A with the content of column B

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

ramin2000
Posts: 11
Joined: Wed Jun 02, 2010 12:02 am

Replace column A with the content of column B

Postby ramin2000 » Wed Sep 15, 2010 2:09 am

Hi all
The following maybe very easy to do but I cant seem to get it done.

Every time ### shows up in column A replace it with the content of column B

Any ideas?

User avatar
DataMystic Support
Site Admin
Posts: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace column A with the content of column B

Postby DataMystic Support » Thu Sep 16, 2010 9:51 am

Are the columns in a CSV file? Tab file? Or just fixed width columns? Are they adjacent columns?

Assuming adjacent fields in a CSV delimited file, find EasyPattern

Code: Select all

"###","[ capture(1+chars) ]"


Replace with

Code: Select all

"$1","$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

ramin2000
Posts: 11
Joined: Wed Jun 02, 2010 12:02 am

Re: Replace column A with the content of column B

Postby ramin2000 » Thu Sep 16, 2010 1:13 pm

pipe text file

User avatar
DataMystic Support
Site Admin
Posts: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace column A with the content of column B

Postby DataMystic Support » Fri Sep 17, 2010 8:16 am

Are the pipe columns adjacent?

If so, use EasyPattern

Code: Select all

|###|[ capture(1+chars) ]|


Replace with

Code: Select all

|$1|$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

websolprov
Posts: 1
Joined: Wed Oct 13, 2010 9:33 pm

Re: Replace column A with the content of column B

Postby websolprov » Wed Oct 13, 2010 9:57 pm

Hi Simon,

Long time no speak, I have data along the lines of the following:
01/10/2010;00:00:00:025;T;AP0Y;235;3;f2=4628;f3=2;f108=19;f1=599;f30=4555;f33=8159;f243=4616
01/10/2010;00:00:00:025;T;AP0Y;235;3;f2=4628;f3=2;f108=19;f1=599;f30=4556;f33=8161;f243=4616
01/10/2010;00:00:00:541;T;AP0Y;235;3;f2=4629;f3=1;f108=19;f1=599;f30=4557;f33=8162;f243=4616

This has been extracted with a "restrict lines to matching" ^(0[1-9]|[1-2][0-9]|3[0-1])/(0[1-9]|[1-2][0-9]|3[0-1])/[0-9]{4}\;([0-9]{2}:){3}([0-9]{3})\;T\;[\@0-9a-zA-Z]*\;[0-9]{1,3}\;[0-9]{1,2}\;

What I need to do is take each of the tags and consolidate them into columns, given the random use of tags and the fact they can be in any order perhaps OUTSIDE the existing column range, then move the "blank columns" left followign the data being moved. There you should end up with f1=x in the same column regardless of order in original data, the f2= in the same column and so forth. I was thinking of a "move column based on "(f2=[0-9]{1,4})" for each of the tag pairs I need but I can only see move nth column etc.

Can you point me in the right direction please? Thanks,

Alex

User avatar
DataMystic Support
Site Admin
Posts: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace column A with the content of column B

Postby DataMystic Support » Thu Oct 14, 2010 7:42 am

Hi Alex,

The only way you can do this is with a Scripting filter that splits out the string using semi-colons (;), examines each column for a fXXX=YYYY value, and if found, loads the f value into an array. At the end of the line, it then needs to spit out every single column from 1 to the maximum value of XXXX, inserting dummy values where needed.
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 6 guests