cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
peri_a
Level III

Referencing columns extracted from parsing Datafilter select where

I want to use a data filter interface for a different use.

Then i need to parse the "select where" clause and use the info in there.

I am able to parse the Where clause and identify the different column in the expression

but not reference them

 

DFClause=Currentdatafilter << get where clause();
SelectInnerExpr=Arg(parse(DFClause),1);
// let assume for a second this will always return an expression of this type to simplify the example
SelectInnerExpr= expr(:study_owner == "name" & :Is Electr. == 1);

//so i can parse it with a simple for loop for(iA=1,iA<=NArg(SelectInnerExpr),iA++, TestColExp=Arg(Arg(SelectInnerExpr,iA),1); // here i can get the column as i need but as :ColumName TestCol=eval(TestColExp); // so this does not really retun the column reference
colname= TestCol<< Get Name; );

however i get the column as :ColumName

how do i now get the column reference to then continue with the script?

colname= TestCol<< Get Name

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
peri_a
Level III

Re: Referencing columns extracted from parsing Datafilter select where

Looking at your suggestion i realizes that 

TestColExp 

Is already the reference to the column i was looking for.

the "eval" in my script was not necessary... 

i could just use 

TestColExp << Get Data Type

for example 

View solution in original post

5 REPLIES 5

Re: Referencing columns extracted from parsing Datafilter select where

Is this what you're looking for? I modified your For() loop to put the first bit into a char, then pulled out and parsed the first word. Full script attached. There are also likely more elegant ways to do this that others may add.

 

For( iA = 1, iA <= N Arg( SelectInnerExpr ), iA++,
	TestColExp = Char( Arg( Arg( SelectInnerExpr, iA ), 1 ) ); // put all into a char()
	TestCol = Parse( Word( 1, TestColExp ) ); //now returns test col
);
peri_a
Level III

Re: Referencing columns extracted from parsing Datafilter select where

Looking at your suggestion i realizes that 

TestColExp 

Is already the reference to the column i was looking for.

the "eval" in my script was not necessary... 

i could just use 

TestColExp << Get Data Type

for example 

Re: Referencing columns extracted from parsing Datafilter select where

This also seems to work, but in the not-that-unusual case of having an open paren in the column name, will fail. You'd have to trap for that if it is a concern.

 

Names Default To Here( 1 );
dt = open("$Sample_Data\Car Physical Data.jmp");
gb  = dt << Graph Builder(
	Size( 526, 668 ),
	Show Control Panel( 0 ),
	Variables( X( :Turning Circle ), Y( :Horsepower ) ),
	Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) ),
	Local Data Filter(
		Show Histograms and Bars( 0 ),
		Add Filter( columns( :Country, :Type ), Display( :Type, N Items( 5 ) ) ),
		Add Filter( columns( :Weight ), Display( :Weight, Height( 20 ) ) )
	)
);




//////////// processing here ob = (report(gb) << parent)[outlinebox(1)]; lis = (ob << xpath( "//TabPageBox" )) << get title; colnames = Transform Each( {v, i}, lis[2 :: (N Items( lis ) - 1)], Trim Whitespace( Items( [1 1], v, "(" )[1] ) );

Re: Referencing columns extracted from parsing Datafilter select where

I should add that it isn't getting the where clause, but rather the columns used in the filter... so that may not suit your needs.

peri_a
Level III

Re: Referencing columns extracted from parsing Datafilter select where

Thanks for the suggestion, but i would need to use the whole clause including the conditions (>10 or =="F").

and do something to the columns based on the selection.