Hi all!
I need to get a small table into a list of Associative Arrays. Where each row is a member of that list and is an Associative Array with column names as keys and row values as values.
Currently I have this:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
listAA = {};
columnList = dt << Get Column Names( string );
For Each Row(
currentAA = Associative Array();
For Each( {columnName, index}, columnList, currentAA[columnName] = Column( dt, columnName ) );
Insert Into( listAA, currentAA );
);
//Check
listAA[1]["age"]
//:*/
listAA[1]["age"]
/*:
Column( "age" )
The output is not a value, but a reference to a column. So looks like it doesn't work when you refer to column using Column(name) inside For Each Row, only hardcoded names like in the Scripting Index:
For Each Row( :height = -:height );
Questions:
1. Is there a simple elegant way to get a list of AAs from a table? If not - how would I need to change my current version?
2. How to refer to a column not in a hardcoded way when using "For Each Row"?
Thanks,
M.