- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Remove {" "} from the outside of a string
Any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Remove {" "} from the outside of a string
you can use the parse() funcction to do that:
x="zippy"; show(parse(x))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
-----
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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], "\!"" );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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, "," );
),
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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, "{", "", "}", "", "\!"", "" ) ),
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Remove {" "} from the outside of a string
Thanks.This works!