Coincidencia de la lista ID_HEX con la tabla de referencia globalHola a todos,
Estoy trabajando en JMP con dos tablas:
- TPMS_Sensor_install_DATA.jmp: contiene una única columna de clave ID_HEX.
- TableID Globale.jmp contiene el ID de la columna clave junto con todas las columnas descriptivas (Ref Producto, Nombre del producto, Fecha, Operador, etc.).
Objetivo: filtrar la tabla global para que solo conserve las filas cuyo ID aparezca en mi lista ID_HEX y luego devuelva solo las columnas Ref Produit y ProductName.
Este es el script que probé: termina devolviendo la tabla global completa sin filtrar:
// 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;
¿Puede alguien ayudarme a corregir este script para que: en realidad filtre TableID Globale por la lista hexadecimal de valores ID_HEX y devuelva solo las columnas Ref Produit y ProductName con el ID coincidente?
¡Cualquier sugerencia o ejemplo de fragmentos de JSL será muy apreciado!
Gracias de antemano !
Automatización y scriptingVentanasRe: Coincidencia de la lista ID_HEX con la tabla de referencia global¿Has probado si unir te basta? Otra opción sería usar "Obtener filas" para obtener las filas de interés y el subconjunto en función de eso.
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 algo similar
Re: Coincidencia de la lista ID_HEX con la tabla de referencia globalLo he probado, pero el script tarda muchísimo y no produce ningún resultado; parece que se bloquea por completo. Para contextualizar, dtGlobal contiene 12 millones de filas y dtSensor, 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: Coincidencia de la lista ID_HEX con la tabla de referencia globalPuede deshacerse de los duplicados en su dtSensor, por ejemplo, usando Resumir, le ayudará un poco.
Summarize(dtSensor, hexList = By(:ID_HEX));
Re: Coincidencia de la lista ID_HEX con la tabla de referencia globalusing 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: Coincidencia de la lista ID_HEX con la tabla de referencia globalEliminé los duplicados de ambas tablas de datos como sugirió Jthi, utilicé el método de matriz asociativa y ¡funcionó!
¡Muchas gracias por la ayuda!
Re: Coincidencia de la lista ID_HEX con la tabla de referencia globalSugeriría usar "Resumir" si solo se utiliza la lista y los valores son cadenas . Usar un array asociativo solo para eliminar duplicados puede resultar lento con conjuntos de datos grandes. La tabla de resumen es más rápida con tablas de datos grandes, pero requiere un poco más de código. Sin embargo, ofrece ventajas como mantener los números como números. El orden también puede ser diferente entre "Associative Array" y "Resumen/Resumir".
Ver más...
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;
Dependiendo de los datos reales, es muy probable que esto se pueda hacer bastante rápido, ya que no hay demasiadas filas que JMP no pueda manejar fácilmente.