Add values from another data table file to current data table fileHi,
Hi, I have a doubt regarding JSL script (very new to this!)
I've two data files- Table A and Table B.
Table A:-
Table B:-

I want to add values from Table B Column name "Offset" to each Rows of Column Group "Tests" in Table A and generate a new data table file with values added.
Here's what I've tried to start with. Any ideas on this or a more efficient way to do it?
Clear Globals();
dt_Table_A = Current Data Table(); //Table A
dt_Table_B = open(); //Select Table B
table_B_colnames =dt_Table_B << Column Names( "Offset" );
table_A_colnames = dt_Table_A << GetColumnNames( Numeric, String );
@txnelson
AnalyticsScriptingRe: Add values from another data table file to current data table file- Please take the time to read the Scripting Guide and to familiarize yourself with the Scripting Index.
- If you need to brush up on general programming skills, there are a large number of sites on the internet that can assist with that.
- Here is the simple script that will do what you want
Names Default To Here( 1 );
dt = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );
For Each Row(
dt:Current = dt:Current + dtOffset:Offset[1];
dt:Voltage = dt:Voltage + dtOffset:Offset[2];
dt:Resistance = dt:Resistance + dtOffset:Offset[3];
dt:Inductance = dt:Inductance + dtOffset:Offset[4];
dt:Capacitance = dt:Capacitance + dtOffset:Offset[5];
dt:Power = dt:Power + dtOffset:Offset[6];
dt:Temperature = dt:Temperature + dtOffset:Offset[7];
dt:Humidity = dt:Humidity + dtOffset:Offset[8];
dt:Pressure = dt:Pressure + dtOffset:Offset[9];
dt:Suseptance = dt:Suseptance + dtOffset:Offset[10];
);
Re: Add values from another data table file to current data table fileMany Thanks @txnelson you are genius 
Re: Add values from another data table file to current data table fileHow can I use a loop to perform addition. There are more than 100 columns in Table A?
Re: Add values from another data table file to current data table fileYou can use
colList = dt << get column names;
to get the names of the columns in the data table
and then use a For() loop
For(i=1,i<=N Items(colList), i++,
.......
.......
.......
);
to perform the operations you need to do for each column.
These are documented in the Scripting guide and Scripting Index......with examples
Re: Add values from another data table file to current data table file@txnelson
Here is what I tried. Im not sure what's wrong. Can you please take a look?
Names Default To Here( 1 );
dt = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );
colList = dt << get column names;
For(i=1; N Rows(dt); i++,
Column(dtOffset)[i] = dt:colList[i] + dtOffset:Offset[i];
);
Re: Add values from another data table file to current data table fileHi @ih,
I want to add values from Table B Column name "Offset" to each Rows of Column Group "Tests" in Table A and generate a new data table file with values added. There are more than 100 columns in Table A. How can I use a loop syntax to iterate to each rows and columns?
Here's what I've tried to start with
Names Default To Here( 1 );
dt = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );
colList = dt << get column names;
For(i=1; N Rows(dt); i++,
Column(dtOffset)[i] = dt:colList[i] + dtOffset:Offset[i];
);
Appreciate if you could suggested