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
ENTHU
Level III

Issue with Words()

Hi,

I have written the following code which functions as follows-

1.Check if column name EPATH exists in the table

2.If yes get all values of the column

3.Need to get the string after last "\" in the column value.

4.The code does work but appends "}" at the end of the value.

 

If( Contains( col_name ,"EPATH" ),
unique_epath = {};
unique_epath = Associative Array(dt:EPATH) << Get Keys;
wordlist=Words(char(unique_epath), "\");
totword=NItems(wordlist);

Column(dtout,"Order")[1] = wordlist[totword-0];
);

 

 

How can I get around this problem?

TIA

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: Issue with Words()

Is this what you are after?

NamesDefaultToHere(1);

dt = New Table( "Test",
				Add Rows( 5 ),
				New Column( "EPATH",
					Character,
					"Nominal",
					Set Values( {"a\b\c", "a\b\c", "d\e\f", "d\e\f", "g\h\i"} )
				)
			);

unique_epath = Associative Array(dt:EPATH) << Get Keys;
lastPart = {};
for(p=1, p<=NItems(unique_epath), p++,
	parts = Words(unique_epath[p], "\");
	InsertInto(lastPart, parts[NItems(parts)])
	);
Print(lastPart);

View solution in original post

2 REPLIES 2
Highlighted
ian_jmp
Staff

Re: Issue with Words()

Is this what you are after?

NamesDefaultToHere(1);

dt = New Table( "Test",
				Add Rows( 5 ),
				New Column( "EPATH",
					Character,
					"Nominal",
					Set Values( {"a\b\c", "a\b\c", "d\e\f", "d\e\f", "g\h\i"} )
				)
			);

unique_epath = Associative Array(dt:EPATH) << Get Keys;
lastPart = {};
for(p=1, p<=NItems(unique_epath), p++,
	parts = Words(unique_epath[p], "\");
	InsertInto(lastPart, parts[NItems(parts)])
	);
Print(lastPart);

View solution in original post

Highlighted
ENTHU
Level III

Re: Issue with Words()

This works.Thank you!
Article Labels

    There are no labels assigned to this post.