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
 Forum for Origin C
 Row Filtering, Extracting interessting values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ckrebs

Germany
1 Posts

Posted - 06/09/2009 :  10:00:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8G SR1
Operating System:Win2000

Hi Forum,

i have a lot of measurment data. Sometimes there is a measurement error which writes a 0 in a row.
So i want to copy the rows consisting Valuea !=0 to a new row.
Is there a Documentation for BOOL Extract somewhre or a nice/fast implementation for this?

best regards,

Iris_Bai

China
Posts

Posted - 06/10/2009 :  02:55:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Christoph,

We have a XFunction "wxt" to extract data from worksheet to new worksheet, or highlight result rows, or add a new column with 0/1 as mark, e.g.

//extract rows that not contain 0 in column 1 and column 2 to a new worksheet
wxt test:="col(1) != 0 AND col(2) != 0" ow:=<new>

//highlight rows that not contain 0 in column 1 and column 2
wxt test:="col(1) != 0 AND col(2) != 0" sel:=1

// put on/off result to column 3 with condition values in column 1 and column 2 all are not 0
wxt test:="col(1) != 0 AND col(2) != 0" val:=3


Or you can use Origin C code. Please refer to following wiki page for detail examples on Worksheet::Extract function:
http://ocwiki.originlab.com/index.php?title=OriginC:Extract_Data_from_Worksheet

Look at strCondition, just change this variable to "col(1)!=0 && col(2)!=0" for your data.

Or use the following codes to generate condition to check value!=0 for all columns:

    string 	strCondition;
    foreach(Column col in wks.Columns)
    {
    	string str;
    	str.Format("col(%d) != 0", col.GetIndex()+1);
    	
    	if( strCondition.IsEmpty() )
    		strCondition = str;
    	else
    		strCondition += " && " + str;    	
    }



Iris

Edited by - Iris_Bai on 06/10/2009 04:28:00 AM
Go to Top of Page

___kfz___

2 Posts

Posted - 03/30/2012 :  09:09:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Iris_Bai

We have a XFunction "wxt" to extract data from worksheet to new worksheet, or highlight result rows, or add a new column with 0/1 as mark, e.g.

//extract rows that not contain 0 in column 1 and column 2 to a new worksheet
wxt test:="col(1) != 0 AND col(2) != 0" ow:=<new>
Iris



Hello,
I have a similar task, I want to select rows for which the value in one column higher than "0" and in another column higher than "1". I guess, then script then will be like this, in analogy:

wxt test:="col(1) > 0 AND col(2) >1" ow:=<new>

My question is how to run this script, where to put this script?
Go to Top of Page

greg

USA
1379 Posts

Posted - 03/30/2012 :  3:22:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To ___kfz___

The Table at the bottom of this page:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=Category:LT_Running_Scripts
lists a number of ways to run scripts in Origin, but the most common is the Script Window or Command Window:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=Script:From_Script_and_Command_Window
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