How to place List values into the columnAs a result of some manipulations I have a list of size of number of rows in my table.
I want to create a new column and place these values into this colum.
JSL reference says that this should work:
dt = New Table( "My Data");
dt << New Column( "Last Name", Character, Values( {"Smith", "Jones",
"Anderson"} ) );
IThe list that I want to put into that column is actually list of lists. If I do Eval(names) I get something like {{"John"}, {"Jim" },{"Jane"}}
How to make it one dimensional list to put into the column?
Thanks!
Re: How to place List values into the columnJim,
Wouldn't it just take the items in the first list (which are already lists) into new list (also in the form of one-tem-lists)?
Anyways, I couldn't find a way to fight it when list already formed, but I did it like this:
In the loop that constracts my list of lists, I have something like this:
for(t=1, t<=NItems(....)....
......
names[t] = someFunctionThatSpitsSingleNameLists[i][j];
);
I do this:
names[t] = Item(2,Char(someFunctionThatSpitsSingleNameLists[rowTool][rowcurrentReplacementDate]), "\!"");
It just evaluates those single name lists like "{"Jim"}" and then takes only Jim - and puts it in names[t] list.
Re: How to place List values into the columnFollowing on @txnelson post...I actually created a little function to do this, as I found myself in the same position many times. This will "flatten" list of lists 2 levels deep for example.
Flatten2DList = Function( {list_arg},
{DefaultLocal},
NewList = {};
For( i = 1, i <= N Items( list_arg), i++,
For( j = 1, j <= N Items( list_arg[i] ), j++,
Insert Into( NewList, list_arg[i][j] );
);
);
NewList;
)Re: How to place List values into the columnYour code does work, however the issue is that the list, "Origlist" is a list of lists, not just a single list, which is the way your have the list defined in your script. So the issue is, how to get the list of lists into the data table.
Re: How to place List values into the columndisregard
Re: How to place List values into the columnThis should do it:
Names Default To Here( 1 );
origlist = {{"John"}, {"Jim"}, {"Jane"}};
newlist = {};
For( i = 1, i <= N Items( origlist ), i++,
Insert Into( newlist, origlist[i] )
);
dt = New Table( "My Data" );
dt << New Column( "Last Name", Character, Values( newlist ) );