The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Deleting columns with specific 'long name'
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

annniia

United Kingdom
2 Posts

Posted - 08/27/2017 :  12:19:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I have been trying to ease my data analysis with labtalk but so far unsuccesfully.
My datasets (about 150 of them) contain X_i, Y_i columns, about 35 of each. There are some X_i columns missing and I can't use the option to skip, because those missing columns are random between datasets. I would like to delete all columns which long name starts with X, except X_0, and I would like to apply this to a few datasets (sheets) at a time.

I already played with the option to set a range that includes several X_i columns but for the amount of data I would be doing that until Christmas

Here is what a dataset looks like:



Thanks in advance!

nick_n

Finland
125 Posts

Posted - 08/27/2017 :  5:57:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Just copy that in Script Window (Alt+Shift+3).
Change strArgument and strArgumentExclud as you wish.
That LT will loop all pages and columns in current book.
Best regards

string strArgument$="X*";
string strArgumentExclud$="X_0";
int ii, jj;

loop (jj, 1, page.nLayers)
{
page.active=jj;
worksheet -s;

loop (ii, 1, wks.nCols)
{

strColLabelName$=wcol(ii)[L]$;
if (strColLabelName.match(strArgument$) && !strColLabelName.matchstrArgumentExclud$)) wks.colSel(ii, 1);
}

domenu 36442;

}


Nikolay
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 08/27/2017 :  6:00:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
oops,
One bracket is missing, check this line:

if (strColLabelName.match(strArgument$) && !strColLabelName.match(strArgumentExclud$))

Nikolay
Go to Top of Page

annniia

United Kingdom
2 Posts

Posted - 08/28/2017 :  3:36:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Works perfectly! Thank you so much!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000