Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
new_2_JMP
Level I

Split a long column begins with a keyword and ends 1 row before another keyword is reached

Split a long column begins with a keyword and ends 1 row before another keyword is reached. Please see attached example Excel file for the data table before and after the split

 

Number of test per frequency is not always the same from as high as test20 to as low as test 13
Number of frequency test is not in an increment of 100 but they can be place in a list. In our example, 
the frequency list is (100, 200, 300, 400, 500, 550, 650)

 

Thanks

new_2-JMP

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Split a long column begins with a keyword and ends 1 row before another keyword is reached

Just create a new column that increments by 1, every time the Original column has Freq in it's value.  Then split on the new column.

Here is a simple script that does it

names default to here(1);
dt=current data table();
dt<<new column("split");
for each row(if(row()==1,hold=0);
	if(left(:Original,4) == "Freq", hold++);
	:split=hold
);

dt << Split(
	Split By( :split ),
	Split( :Original ),
	Sort by Column Property
);
Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Split a long column begins with a keyword and ends 1 row before another keyword is reached

Just create a new column that increments by 1, every time the Original column has Freq in it's value.  Then split on the new column.

Here is a simple script that does it

names default to here(1);
dt=current data table();
dt<<new column("split");
for each row(if(row()==1,hold=0);
	if(left(:Original,4) == "Freq", hold++);
	:split=hold
);

dt << Split(
	Split By( :split ),
	Split( :Original ),
	Sort by Column Property
);
Jim

View solution in original post

Highlighted
new_2_JMP
Level I

Re: Split a long column begins with a keyword and ends 1 row before another keyword is reached

Hi txnelson,

Thanks a lot for your helps, it works but can you help explain to me the meaning the of below codes:

 

if(row()==1,hold=0)

    row()==1:  are you checking for non empty row?

    hold = 0: what does this do?

 

if(left(:Original,4) == "Freq", hold++);

   left(:Original,4): I do not understand the meaning of left, : Original and 4

 

Thanks

Dat N

Article Labels

    There are no labels assigned to this post.