Ciao,
Ho un sistema che calibra i dati e restituisce le informazioni in questo modo:
| ID pneumatico | Filo | Profondità | Trascinare | noi | psi |
| 2326 | Interno | 0,618584 | 0,117774 | 0,417314 | 21.15549 |
| 2326 | Esterno | 0,740841 | 0,417079 | 0,417314 | 21.15549 |
| 2327 | Interno | 0.329065 | 0.218903 | 0.365071 | 25.65573 |
| 2327 | Esterno | 0,478055 | 0,214953 | 0.365071 | 25.65573 |
L'ID del pneumatico viene letto due volte, una per le letture del battistrada interno e una per l'esterno. C'è uno script che posso usare per riorganizzarlo come tale:
| ID pneumatico | Profondità interna | Profondità esterna | Resistenza interna | Resistenza esterna | noi | psi |
| 2326 | 0.61858445 | 0.74084057 | 0.1177737 | 0.4170794 | 0,41731 | 21.1555 |
| 2327 | 0.32906451 | 0.47805545 | 0.2189025 | 0.2149527 | 0,36507 | 25.6557 |
Qui c'è solo una voce per pneumatico. Le voci per Profondità e Trascina sono state rinominate in Interno o Esterno e le colonne identiche sono state appena unite in una sola. Questo è un frammento di un foglio molto più grande con molte più colonne, alcune diverse, altre uguali.
Idealmente, lo script può determinare quali celle sono le stesse in base all'ID stanco e rimuovere semplicemente le repliche. Ma anche uno script impostato con nomi predeterminati potrebbe funzionare, poiché i nomi delle colonne non cambiano mai.
Grazie!
@jthi , @txnelson , voi due avete aiutato moltissimo l'ultima volta! Grazie per questo! Non so davvero quale approccio adottare e non sono stato in grado di trovare nulla di abbastanza simile nelle soluzioni precedenti.
Questo è un approccio di forza bruta, ma funziona.Nota le variabili per colonne divise e colonne non divise.
dt = New Table( "Base Tire Data", Add Rows( 4 ),
New Column( "Tire ID", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [2326, 2326, 2327, 2327] ) ),
New Column( "Tread", Character( 16 ), "Nominal",
Set Values( {"Inner", "Outer", "Inner", "Outer"} ) ),
New Column( "Depth", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [0.618584, 0.740841, 0.329065, 0.478055] ) ),
New Column( "Drag", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [0.117774, 0.417079, 0.218903, 0.214953] ) ),
New Column( "uS", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [0.417314, 0.417314, 0.365071, 0.365071] ) ),
New Column( "psi", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [21.15549, 21.15549, 25.65573, 25.65573] ) )
);
nr = nrows(dt);
dtt = New Table( "Split Tires");
dtt << new column("Tire ID", Numeric, "Continuous", Format( "Best", 12 ));
split_cols = {"Depth", "Drag"};
nonsplit_cols = {"uS", "psi"};
for (i = 1, i <= nitems(split_cols), i++,
inn_col = "Inner " || split_cols[i];
out_col = "Outer " || split_cols[i];
dtt << new column(inn_col, Numeric, "Continuous", Format( "Best", 12 ));
dtt << new column(out_col, Numeric, "Continuous", Format( "Best", 12 ));
);
for (i = 1, i <= nitems(nonsplit_cols), i++,
one_col = nonsplit_cols[i];
dtt << new column(one_col, Numeric, "Continuous", Format( "Best", 12 ));
);
dtt << Add Rows( nr/2 );
k = 0;
for (i = 1, i <= nr, i+=2,
k++;
for (m = 1, m <= nitems(split_cols), m++,
one_col = split_cols[m];
inn_col = "Inner " || split_cols[m];
out_col = "Outer " || split_cols[m];
column(dtt, inn_col)[k] = column(dt, one_col)[i];
column(dtt, out_col)[k] = column(dt, one_col)[i+1];
);
column(dtt, "Tire ID")[k] = column(dt, "Tire ID")[i];
for (m = 1, m <= nitems(nonsplit_cols), m++,
one_col = nonsplit_cols[m];
column(dtt, one_col)[k] = column(dt, one_col)[i];
);
);