cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
BladeRunner
Level II

Deleting a row based on the presence of specific words in a cell

Hello All!  I think this might be a common situation for many working with data files from various instruments. My data sets are derived from stitching multiple output files from a specific instrument.  Besides the useful data rows, there are a number of rows on top of each output file that specify the Recipe, File, and others, typically, this info is in Column 1.  For processing the data, I do not need that info, so I want to delete the unnecessary rows containing the above words Recipe, File, etc. in the cells in Column 1.  Note that there might be other words in the same cells, for example: "Wafer Recipe Name", or "Stage Group File", etc.  I tried a number of permutations on the following, but I always get an error message saying: "Send expects scriptable objects in access of evaluation of "Send", etc.  Many thanks in advance!

 

dt_new2 << get rows where (contains (:Column 1, "Recipe"));
dt_new2 << delete rows;
Wait(1);

 

dt_new2 << get rows where (contains (:Column 1, "File"));
dt_new2 << delete rows;
Wait(1)

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Deleting a row based on the presence of specific words in a cell

Try this

Names Default To Here( 1 );
dt_new2 = Current Data Table();
dt_new2 << select where( Contains( :Column 1, "Recipe" ) );
dt_new2 << delete rows;
Wait( 0 );

dt_new2 << select where( Contains( :Column 1, "File" ) );
dt_new2 << delete rows;

The Scripting Index

     Help=>Scripting Index

is a great source of statement syntax and examples.

Also, I advise you to take the time to read through the Scripting Guide found in the JMP Help

 

Jim

View solution in original post

jthi
Super User

Re: Deleting a row based on the presence of specific words in a cell

If you wish to just use << Delete Rows without any arguments, you have to select rows (like Jim did show). Other option is to collect your rows into a variable and use that (my preferred method as it skips "unnecessary" row selection but selection is more visual if you wish to debug)

Names Default To Here(1);

rows_to_delete = dt_new2 << get rows where(Contains(:Column 1, "Recipe"));
dt_new2 << delete rows(rows_to_delete); 

rows_to_delete = dt_new2 << get rows where(Contains(:Column 1, "File"));
dt_new2 << delete rows(rows_to_delete);

This behaviour is not documented in Scripting Index,

jthi_0-1723608431578.png

but it can be found from JSL Syntax Reference Data Table Messages (jmp.com) and Scripting Guide Delete Rows (jmp.com) (search Delete Rows from Script Editor and press Topic Help)

-Jarmo

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Deleting a row based on the presence of specific words in a cell

Try this

Names Default To Here( 1 );
dt_new2 = Current Data Table();
dt_new2 << select where( Contains( :Column 1, "Recipe" ) );
dt_new2 << delete rows;
Wait( 0 );

dt_new2 << select where( Contains( :Column 1, "File" ) );
dt_new2 << delete rows;

The Scripting Index

     Help=>Scripting Index

is a great source of statement syntax and examples.

Also, I advise you to take the time to read through the Scripting Guide found in the JMP Help

 

Jim
BladeRunner
Level II

Re: Deleting a row based on the presence of specific words in a cell

Hi, txnelson, thank you for your reply!  Like I said, I tried a bunch of related commands, including select where + contains, but without the statement Names default to here at the top, that approach did not work previously.  The routine works for me now, many thanks for the input.  Cheers!

jthi
Super User

Re: Deleting a row based on the presence of specific words in a cell

If you wish to just use << Delete Rows without any arguments, you have to select rows (like Jim did show). Other option is to collect your rows into a variable and use that (my preferred method as it skips "unnecessary" row selection but selection is more visual if you wish to debug)

Names Default To Here(1);

rows_to_delete = dt_new2 << get rows where(Contains(:Column 1, "Recipe"));
dt_new2 << delete rows(rows_to_delete); 

rows_to_delete = dt_new2 << get rows where(Contains(:Column 1, "File"));
dt_new2 << delete rows(rows_to_delete);

This behaviour is not documented in Scripting Index,

jthi_0-1723608431578.png

but it can be found from JSL Syntax Reference Data Table Messages (jmp.com) and Scripting Guide Delete Rows (jmp.com) (search Delete Rows from Script Editor and press Topic Help)

-Jarmo
BladeRunner
Level II

Re: Deleting a row based on the presence of specific words in a cell

Hi jthi, thank you for your reply, I appreciate it.  I always remind myself to rely more on variables, but unfortunately, I do it only when there are no other options.  A great suggestion, I am sure it will be useful to many others.  Cheers!

jthi
Super User

Re: Deleting a row based on the presence of specific words in a cell

You can also do it without variables but I wouldn't suggest it as it is much more difficult to read and harder to debug if there are any issues

Names Default To Here(1);

dt_new2 << delete rows(dt_new2 << get rows where(Contains(:Column 1, "Recipe"))); 
dt_new2 << delete rows(dt_new2 << get rows where(Contains(:Column 1, "File")));
-Jarmo