Corrispondenza dell'elenco ID_HEX alla tabella di riferimento globaleCiao a tutti,
Sto lavorando in JMP con due tabelle:
- TPMS_Sensor_install_DATA.jmp: contiene una singola colonna chiave ID_HEX.
- TableID Globale.jmp contiene l'ID della colonna chiave insieme a tutte le colonne descrittive (Ref Produit, ProductName, Date, Operator, ecc.).
Obiettivo: filtrare la tabella globale in modo che mantenga solo le righe il cui ID appare nell'elenco ID_HEX e quindi restituire solo le colonne Ref Produit e ProductName.
Ecco lo script che ho provato: finisce per restituire l'intera tabella globale non filtrata:
// 1. Open both tables invisibly
dtSensor = Open( "D:\\Project JMP\\IDEnorme\\TPMS_Sensor_install_DATA.jmp", Invisible );
dtGlobal = Open( "D:\\Project JMP\\Tables Données\\TableID Globale.jmp", Invisible );
// 2. Extract the list of ID_HEX values from dtSensor
hexList = Column( dtSensor, "ID_HEX" ) << Get Values;
// 3. Subset dtGlobal: keep only rows where :ID is in hexList,
// and select only Ref Produit + ProductName
dtResult = dtGlobal << Subset(
Where( Contains( hexList, :ID ) ),
Select(
:"Ref Produit",
:"ProductName"
),
Output Table Name( "Résultats Correspondance" )
);
// 4. Show the result
dtResult << Show Window;
Qualcuno può aiutarmi a correggere questo script in modo che: filtri effettivamente TableID Globale in base all'elenco esadecimale dei valori ID_HEX e restituisca solo le colonne Ref Produit e ProductName con l'ID corrispondente.
Qualsiasi suggerimento o frammento di esempio JSL sarebbe molto apprezzato!
Grazie in anticipo !
Automazione e scriptingFinestreRe: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globaleHai provato se join sarebbe sufficiente per te? Un'altra opzione sarebbe usare << Ottieni righe. Dove ottenere le righe di interesse e un sottoinsieme basato su di esse.
rows_of_interest = dtGlobal << Get Rows Where(Contains(hexList, :ID));
dt_new = dtGlobal << Subset(Rows(rows_of_interest), Columns(:Ref Produit, :ProductName), Output table("Filtered"));
o qualcosa di simile
Re: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globaleL'ho provato, ma lo script impiega moltissimo tempo e non produce alcun output, sembra bloccarsi completamente. Per contestualizzare, dtGlobal contiene 12 milioni di righe e dtSensor ne contiene 400.000.
dtSensor = Open( "D:\\Project JMP\\IDEnorme\\TPMS_Sensor_install_DATA.jmp", Invisible );
dtGlobal = Open( "D:\\Project JMP\\Tables Données\\TableID Globale.jmp", Invisible );
hexList = Column( dtSensor, "ID_HEX" ) << Get Values;
rows_of_interest = dtGlobal << Get Rows Where(
Contains( hexList, :ID )
);
dtResult = dtGlobal << Subset(
Rows( rows_of_interest ),
Select(
:Ref Produit,
:ProductName
),
Output Table Name( "Résultats Correspondance" )
);
dtResult << Show Window;
Re: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globalePuoi eliminare i duplicati sul tuo dtSensor ad esempio utilizzando Summarize, ti aiuterà leggermente
Summarize(dtSensor, hexList = By(:ID_HEX));
Re: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globaleusing an associative array, you should see <2 minutes</CODE></P>
<PRE><CODE class=" language-jsl">dtSensor = Open( "$DESKTOP/TPMS_Sensor_install_DATA.jmp" );
hexList = Column( dtSensor, "ID_HEX" ) << Get Values; //1048575
lookup = Associative Array( hexList );//231356
hexList = lookup << getkeys; // the keep list.
// manufacture a 12 million row table with 50% matches
n = 12e6; // about 1/4 minute to build a test table...
dtGlobal = New Table( "Untitled",
Add Rows( n ),
New Column( "ID_HEX",
Character,
"Nominal",
Set Values( Transform Each( {v}, Repeat( {"1", "0"}, n / 2 ), If( v == "1", "badc0de", hexlist[Random Integer( 1, N Items( hexlist ) )] ) ) )
),
New Column( "Ref Produit", setvalues( 1 :: n ) ), // even rows match the keep list
New Column( "ProductName", setvalues( 1 :: n ) ) // odd rows are badc0de, not in keep list
);
unwantedrows = dtGlobal << get rows where( !(lookup << Contains( ID_HEX )) ); // about a minute to identify the rows
dtGlobal << deleterows( unwantedrows );
Re: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globaleHo rimosso i duplicati da entrambe le tabelle dati come suggerito da Jthi, ho utilizzato il metodo array associativo e ha funzionato!
Grazie mille per l'aiuto!
Re: Abbinamento dell'elenco ID_HEX alla tabella di riferimento globaleSuggerirei di usare Summarize se si utilizza solo l'elenco E i valori sono stringhe . L'utilizzo di array associativi per la sola rimozione dei duplicati può risultare lento con set di dati più grandi. La tabella di riepilogo è più veloce con tabelle di dati di grandi dimensioni, ma richiede un po' più di codice, ma offre vantaggi come la conservazione dei numeri come numeri. L'ordinamento potrebbe anche essere diverso tra array associativi e Summary/Summarize.
Scopri di più...
Names Default To Here(1);
dttemp = Open("$DOWNLOADS/TPMS_Sensor_install_DATA.jmp");
hexList = Column(dttemp, "ID_HEX") << Get Values;
lookup = Associative Array(hexList);
hexList = lookup << getkeys;
n = 12e6;
dt = New Table("Untitled",
Add Rows(n),
New Column("ID_HEX",
Character,
"Nominal",
Set Values(
Transform Each({v}, Repeat({"1", "0"}, n / 2),
If(v == "1",
"badc0de",
uniq[Random Integer(1, N Items(uniq))]
)
)
)
),
Private
);
Close(dttemp, no save);
wait(0);
s = Tick Seconds();
Summarize(dt, uniq_summarize = By(:ID_HEX));
wait(0);
summarize_dur = Tick Seconds() - s;
wait(0);
s = Tick Seconds();
uniq_aa = Associative Array(:ID_HEX) << get keys;
wait(0);
aa_dur = Tick Seconds() - s;
wait(0);
s = Tick Seconds();
vals = Column(dt, "ID_HEX") << Get Values;
aa = Associative Array(vals);
uniq_aa2 = Associative Array(aa) << get keys;
wait(0);
aa2_dur = Tick Seconds() - s;
wait(0);
s = Tick Seconds();
dt_summary = dt << Summary(
Group(:ID_HEX),
Freq("None"),
Weight("None"),
output table name("Summary of Untitled grouped by ID_HEX"),
Private
);
uniq_summary = dt_summary[0, 1];
Close(dt_summary, no save);
wait(0);
summary_dur = Tick Seconds() - s;
Close(dt, no save);
Show(N Items(uniq_summarize), N Items(uniq_aa), N Items(uniq_aa2), N Items(uniq_summary));
Show(summarize_dur, aa_dur, aa2_dur, summary_dur);
N Items(uniq_summarize) = 231357;
N Items(uniq_aa) = 231357;
N Items(uniq_aa2) = 231357;
N Items(uniq_summary) = 231357;
summarize_dur = 2.36666666666861;
aa_dur = 32.5166666666628;
aa2_dur = 32.25;
summary_dur = 1.30000000000291;
A seconda dei dati reali, questa operazione può essere eseguita molto velocemente, poiché non ci sono troppe righe che JMP può gestire facilmente.