cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Jemster
Level III

Loop for Deleting Rows

I have a loop for deleting rows where the column value isn't what I want

When I run the loop I keep the first set of rows meeting my specifications then it deletes all other rows. I am importing from an excel file and it has several rows in succession of what I want then a gap with other data then later another several. I only get the first set

N_loop = N Rows(dt_a);
i_loop = 0;

While(N_loop > i_loop,
	If( And(dt_a:Column 7[N_loop] != "example 1", dt_a:Column 7[N_loop] != "example 2"),
		dt_a << Delete Row(N_loop)
	);
	N_loop = N_loop - 1
);

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

View solution in original post

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim

View solution in original post

2 REPLIES 2
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim