Espr e Nome EsprCiao,
Sto analizzando quantità maggiori di dati, 350.000 righe.
Per ogni riga, il codice esegue un ciclo per calcolare il delta univoco tra la tabella 1 e la tabella 2 e quindi aggiungere tale delta alla colonna della tabella dati principale. Qualcosa non è corretto nel codice seguente. Qualche suggerimento?
Names Default To Here( 1 );
dt1 = Data Table( "dt_ref" );
dt2 = Data Table( "Data table" );
digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.<BR />
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
dt2 << Add Row( 1, At Start );
dt2 << Begin Data Update;
For Each( {element, idx}, itsel1,
Eval(
Eval Expr(
Column( dt2, element ) << Set Each Value(
Expr(
Name Expr( Column( dt2, element ) )
),
Expr(
Num(
Substr( Char( Column( dt1, "Median" )[dt1 << get rows where( :Tests == element )] - Column( dt2, element ) ), 1, digt + 1 )
) + Column( dt2, element )
)
)
)
)
);
dt2 << Delete Row( 1 );
dt2 << End Data Update;
Grazie,
Jackie
Automazione e scriptingRe: Espr e Nome EsprNon sono sicuro del tipo di calcolo che stai eseguendo qui
Num(Substr(Char(Column(dt1, "Median")[dt1 << get rows where(:Tests == element)] - Column(dt2, element)), 1, digt + 1)) + Column(dt2, element)
ma qualcosa del genere potrebbe aiutarti
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/dt_ref.jmp");
dt2 = Open("$DOWNLOADS/Data table.jmp");
digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.
dt2_colnames = dt2 << Get Column Names("String");
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
For Each({colname}, itsel1,
dt2_col_idx = Contains(dt2_colnames, colname);
If(dt2_col_idx == 0,
Print("Skipped column: " || colname);
continue(); // skip this column
);
dt1_row_idx = Loc(dt1[0, "Tests"], colname);
If(N Items(dt1_row_idx) == 0,
Print("Skipped row: " || colname);
continue();
,
dt1_row_idx = dt1_row_idx[1];
);
dt2[0, dt2_col_idx] = dt2[0, dt2_col_idx] - dt1[dt1_row_idx, "Median"];
);Re: Espr e Nome EsprQuindi sto cercando di allineare i dati in dt2 con i valori medi di Test in dt1
Quindi il valore medio della corrente A1 è 5.408, quindi sottrai ciascuna riga della corrente A1 in dt2 e aggiungila ai valori della riga della corrente A1 in dt2
5.408 - 2.4963333333 = 2.912
2,912 + 2,496333333 = 5,40. Evitando i tradizionali cicli for bcos ho un enorme set di dati con 1 milione di righe ed Expr sarebbe più veloce

Re: Espr e Nome EsprNon ti ritroveresti con il valore mediano se non arrotondi i tuoi valori?
x = mediana,
y = valore della riga,
z = risultato
x - y = z
z + y = x?
Re: Espr e Nome Espr@jthi Esatto, ma voglio arrotondare "z" a 2 decimali e poi aggiungerlo nuovamente a y. Il motivo è "compensare i dati del tester con i dati anagrafici"