TPMS_Sensor_install_DATA.jmp : contains a single key column ID_HEX.
TableID Globale.jmp contains the key column ID along with all the descriptive columns (Ref Produit, ProductName, Date, Operator, etc.).
Goal: Filter the global table so that it only keeps rows whose ID appears in my ID_HEX list, and then return only the Ref Produit and ProductName columns.
Here’s the script I’ve tried—it ends up returning the entire global table unfiltered:
// 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;
Can someone help me correct this script so that it: actually filters TableID Globale by the hexList of ID_HEX values, and returns only the Ref Produit and ProductName columns with the ID matched.
Any pointers or example JSL snippets would be greatly appreciated!
using an associative array, you should see <2 minutes
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: Matching ID_HEX List to Global Reference Table
Created:
Jul 9, 2025 11:08 AM
| Last Modified: Jul 9, 2025 8:10 AM(418 views)
| Posted in reply to message from jthi 07-09-2025
I’ve tried it, but the script takes an extremely long time and produces no output it seems to hang completely. For context, dtGlobal contains 12 million rows and dtSensor contains 400 000.
using an associative array, you should see <2 minutes
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 );
I would suggest using Summarize if just the list is being utilized AND the values are strings. Using associative array for just duplicate removal does get slow with larger datasets. Summary table is fastest with large data tables, but it does require slightly more code, but it does have benefits such as keeping numbers as numbers. The ordering may also be different between Associative Array and Summary/Summarize