cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
twillkickers
Level III

Remove {" "} from the outside of a string

I am trying to extract a value out of a table using the following JSL:

::GlobalVariable= :Column[RowNumber]

However, my output for ::GlobalVariable has unwanted {" "} around it. How do I remove this/prevent this from happening? Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Remove {" "} from the outside of a string

It appears that your column that you have nemed "Column" has list values saved in it.  That wouls account for the {} in your variable called ::GlobalVariable.  And that inside the list definition, there is a string element, which is where the "" are coming from.  I am assuming that you did not intend for the values within :Column to be this.  So I would look to see where the values are coming from, rather than trying to delete them after the fact.  But if that is not possible, I would use the Word function if the value has {""} imbedded in a string, or if it is actually being returned as a true list, then you can simply specify a subscript to get rid of the list component.

::GlobalVariable = word(1,:Column[RowNumber],"{}");
// or
::GlobalVariable = :Column[RowNumber][1];

 

Jim

View solution in original post

9 REPLIES 9
txnelson
Super User

Re: Remove {" "} from the outside of a string

It appears that your column that you have nemed "Column" has list values saved in it.  That wouls account for the {} in your variable called ::GlobalVariable.  And that inside the list definition, there is a string element, which is where the "" are coming from.  I am assuming that you did not intend for the values within :Column to be this.  So I would look to see where the values are coming from, rather than trying to delete them after the fact.  But if that is not possible, I would use the Word function if the value has {""} imbedded in a string, or if it is actually being returned as a true list, then you can simply specify a subscript to get rid of the list component.

::GlobalVariable = word(1,:Column[RowNumber],"{}");
// or
::GlobalVariable = :Column[RowNumber][1];

 

Jim
ENTHU
Level IV

Re: Remove {" "} from the outside of a string

I am facing the same problem with slight variation. I combine 2 columns and get the values of resulting column as a list.
I then assign this list to a cell.When I do so,the output is {"100@boiling","0@melting"}.
I need to remove {" "}.How can I do this?

Below is my code-

//Combine temperature and process step columns to get test temperature
dtCombined = dtSorted << Combine Columns(
delimiter( "@" ),
Columns(
:Temperature,
:process
),
//Selected Columns are Indicator Columns( 1 ),
Column Name( "Process_Temperature" )
);



unique_vals = {};
unique_vals = Associative Array(dtSorted:Process_Temperature) << Get Keys;
Column(dtemplate,"Value")[30] = Char(unique_vals) ;
ENTHU
Level IV

Re: Remove {" "} from the outside of a string

I am able to remove {} using the solution mentioned above.But I need to take the " " (quotes) out as well.
Any help is appreciated.
txnelson
Super User

Re: Remove {" "} from the outside of a string

you can use the parse() funcction to do that:

x="zippy"; show(parse(x))
Jim
ENTHU
Level IV

Re: Remove {" "} from the outside of a string

My list is {"100@boiling","0@melting"}.

I first used word function to remove {} which works fine.

But when I do parse(),I see an error -

Unexpected ",". Perhaps there is a missing ";" or ",".
Line 1 Column 7: 

The remaining text that was ignored was
-----

txnelson
Super User

Re: Remove {" "} from the outside of a string

Since the data is in a data table, the following should work:

Names Default To Here( 1 );
dt = New Table( "Untitled 8",
	Add Rows( 1 ),
	New Column( "Column 1",
		Character,
		"Nominal",
		Set Values( {"{\!"100@boiling\!",\!"0@melting\!"}"} )
	)
);

dt << New Column( "converted", character );

dt:converted[1] = Word( 2, dt:column 1[1], "\!"" ) || "," ||
Word( 4, dt:column 1[1], "\!"" ); 

convert.PNG

Jim
pmroz
Super User

Re: Remove {" "} from the outside of a string

It's a little cleaner with concat items.

New Table( "Test", Add Rows( 1 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"{\!"100@boiling\!",\!"0@melting\!"}"} )
	),
	New Column( "Column 2", Character, "Nominal",
		Formula(
			one_list = Eval( Parse( :Column 1 ) );
			Concat Items( one_list, "," );
		),
	)
);
pmroz
Super User

Re: Remove {" "} from the outside of a string

You can also use substitute to remove {} and ".

New Table( "Test", Add Rows( 1 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"{\!"100@boiling\!",\!"0@melting\!"}"} )
	),
	New Column( "Column 2", Character, "Nominal",
		Formula( Substitute( :Column 1, "{", "", "}", "", "\!"", "" ) ),
	)
);
ENTHU
Level IV

Re: Remove {" "} from the outside of a string

Thanks.This works!