- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
how to convert column names to a list of strings
Hi,
I would like to convert column names to strings but I do not know how.
dt = Open( "$SAMPLE_DATA/Decathlon.jmp" );
col_names = dt << Get Column Names();
Show(col_names);
this leads to
col_names = {Name, Country, Score, Name("100m"), Long Jump, Shot Put, High Jump, Name("400m"), Name("100m hurdles"), Discus, Pole Vault, Javelin, Name("1500m")};
I would like to have something like this instead:
col_names = {"Name", "Country", "Score", "100m", "Long Jump", "Shot Put", "High Jump", "400m", "100m hurdles", "Discus", "Pole Vault", "Javelin", "1500m"};
Any idea?
Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
Thank you for your answer.
Unfortunately your code returns
{Empty()}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
I had some issues with the Community software, and you may have got an incomplete version. At any rate, the code there now gives me (JMP Pro 13.1 on a Mac):
{:height, :weight}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
I use JMP Pro 12.2.0. That might be the reason why our results differ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
It's possible the expression for the Graph Builder saved script has changed, and if so, the way the script is parsed would need to be changed accordingly. I don't have that version installed so can't easily check.
But you should be able to use the general appoach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
For JMP 12, use col_str = dt << Get Column Names( "String" );
As Ian suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
Since your stated purpose is to have the same colors from Graph Builder apply to other graphs, could you use the Column Properties - Value Colors to accomplish what you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
suppose I have a single column name as a variable, how would I make that column name into a string? E.g. a user dialog selects a column, I want that column name as a string. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
the below will assign a string value of a columns name, for the first selected column in the current active data table.
dt = current data table();
theName = ((dt<<get selected columns)[1]) << get name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
I have the opposite problem. I need to convert a string list to a column name list.
I have a list of column names as strings, {"col1", "col2", "col3"}
I want to group those columns but that function needs the list to look like this:
dt << Group Columns("ColGroup", {:col1, :col2, :col3});
I've tried many permutations of eval, evapexpr and column but have not found the correct one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to convert column names to a list of strings
This works:
dt = current data table();
col_list = {"Column 1", "Column 2", "Column 3"};
dt << Group Columns("ColGroup", col_list);