- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
if any easy script for wild card. want to select columns by using wild card
OK, is there an easy general way to use wild card in jmp scripting? I need to list all columns that start with 'Row' (like Row1 Row2 Row3...) in COLUMN COMBINE commend. Thanks.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
Don't know. This works for me.
Names default to here(1);
dt = New Table( "Untitled 231",
Add Rows( 1 ),
New Column( "ID", Set Values( [1] )),
New Column( "Row1", character, Set Values( {"a"} )),
New Column( "Row2", character, Set Values( {"b"} )),
New Column( "Row3", character, Set Values( {"c"} )),
New Column( "Row4", character, Set Values( {"d"} )),
New Column( "Row5", character, Set Values( {"e"} )),
);
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
dt << Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
You can wildcard, but it will only get the first.
dt = open("$SAMPLE_DATA\Big Class.jmp");
Column(dt, "?eight"); //Column( "height" )
it's an easy enough loop though
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
partial_column(".eight"); // {"height", "weight"}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
I want to combine Row1 to Row5 (i want it automate since i may have Row100 in real dataset), and I cannot just wild card like this? If I add the loop, not sure where to put it.
EG Dataset;
ID Row1 Row2 Row3 Row4 Row5 ALL
1 a b c d e a b c d e
My code:
Data Table( "Transpose of stack sort") <<
Combine Columns(
partial_column("Row?"),
Column Name( "ALL" ),
Delimiter( " " )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
Two things, you need to put Columns() around your columns, and wildcards for regex is "."
So you probably need to do something like this
Data Table( "Transpose of stack sort") <<
Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
This sounds the solution, but I got this error when I run it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
Don't know. This works for me.
Names default to here(1);
dt = New Table( "Untitled 231",
Add Rows( 1 ),
New Column( "ID", Set Values( [1] )),
New Column( "Row1", character, Set Values( {"a"} )),
New Column( "Row2", character, Set Values( {"b"} )),
New Column( "Row3", character, Set Values( {"c"} )),
New Column( "Row4", character, Set Values( {"d"} )),
New Column( "Row5", character, Set Values( {"e"} )),
);
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
dt << Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: if any easy script for wild card. want to select columns by using wild card
You might be able to use JMP Patterns for this task.