cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
bio_guy
Level I

How Can I Delete Rows Given A Condition in JSL

Hello. I am a JSL rookie but have some scripting experience with VBA and Python.

 

I have a table that has two columns 'purification_run' and 'parent_purification_runs'. I want to delete each row that has a 'purification_run' field that is contained in any of the 'parent_purification_runs' fields. I wrote the following JSL script to accomplish this, and it runs, but does not perform the intended deletion. Can someone help put me on the right track? Thanks!

 

// Get handles to the columns
purificationRunCol = Column("purification_run");
parentPurificationRunsCol = Column("parent_purification_runs");

// Get the list of all unique parent_purification_runs values
allParentPurificationRuns = parentPurificationRunsCol << Get Values;

// Iterate through each row
For Each Row(
    // Get the purification_run value for the current row
    currentPurificationRun = purificationRunCol << Get As String;

    // Check if the purification_run is present in the list of parent_purification_runs
    If(Contains(allParentPurificationRuns, currentPurificationRun),

        // Delete the row if the condition is true
        Current Data Table() << Delete Rows;
    );
);
1 REPLY 1
txnelson
Super User

Re: How Can I Delete Rows Given A Condition in JSL

This is one way of handing the issue

Names Default To Here( 1 );

dt = Current Data Table();

// Get the list of all parent_purification_runs values
allParentPurificationRuns = :parent_purification_runs << get values;

For Each Row(
	If( Contains( allParentPurificationRuns, :purification_run ),
		dt << Select Rows( Row() )
	)
);

Try( dt << delete rows );
Jim