"[SOLVED] How to filter string"
CharlieFirpo
New Altair Community Member
Dear all!
I have a table with one column that has string values like string1string2string3.... I want filter out only the rows that contains specific string like string2.
Can you help me to solve this? The string1string2... can contain special characters like " , : ...
In SQL, I can use a query like this: SELECT * FROM <table name> WHERE <column name> LIKE '%<specific string>%'
Thank you!!!
I have a table with one column that has string values like string1string2string3.... I want filter out only the rows that contains specific string like string2.
Can you help me to solve this? The string1string2... can contain special characters like " , : ...
In SQL, I can use a query like this: SELECT * FROM <table name> WHERE <column name> LIKE '%<specific string>%'
Thank you!!!
0
Answers
-
Hello
One way is to generate a new attribute that is set to true or false depending on whether it matches. From there filter out the false values and for completeness remove the new attribute.
Here's an example<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Andrew
<process version="5.3.008">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="generate_data_user_specification" compatibility="5.3.008" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="75">
<list key="attribute_values">
<parameter key="string" value=""string1string2string3""/>
</list>
<list key="set_additional_roles"/>
</operator>
<operator activated="true" class="generate_data_user_specification" compatibility="5.3.008" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="165">
<list key="attribute_values">
<parameter key="string" value=""string1string4string3""/>
</list>
<list key="set_additional_roles"/>
</operator>
<operator activated="true" class="generate_data_user_specification" compatibility="5.3.008" expanded="true" height="60" name="Generate Data by User Specification (3)" width="90" x="45" y="255">
<list key="attribute_values">
<parameter key="string" value=""string2""/>
</list>
<list key="set_additional_roles"/>
</operator>
<operator activated="true" class="append" compatibility="5.3.008" expanded="true" height="112" name="Append" width="90" x="246" y="75"/>
<operator activated="true" class="generate_attributes" compatibility="5.3.008" expanded="true" height="76" name="Generate Attributes" width="90" x="380" y="75">
<list key="function_descriptions">
<parameter key="match" value="matches(string,".*string2.*")"/>
</list>
</operator>
<operator activated="true" class="filter_examples" compatibility="5.3.008" expanded="true" height="76" name="Filter Examples" width="90" x="514" y="75">
<parameter key="condition_class" value="attribute_value_filter"/>
<parameter key="parameter_string" value="match=true"/>
</operator>
<operator activated="true" class="select_attributes" compatibility="5.3.008" expanded="true" height="76" name="Select Attributes" width="90" x="648" y="75">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="|match"/>
<parameter key="invert_selection" value="true"/>
</operator>
<connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
<connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 2"/>
<connect from_op="Generate Data by User Specification (3)" from_port="output" to_op="Append" to_port="example set 3"/>
<connect from_op="Append" from_port="merged set" to_op="Generate Attributes" to_port="example set input"/>
<connect from_op="Generate Attributes" from_port="example set output" to_op="Filter Examples" to_port="example set input"/>
<connect from_op="Filter Examples" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
<connect from_op="Select Attributes" from_port="example set output" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>0 -
Once you have set up a database connection (Tools > Manage Database Connections) you can use the "Read Database" operator and its query property to write an SQL query.CharlieFirpo wrote:
In SQL, I can use a query like this: SELECT * FROM <table name> WHERE <column name> LIKE '%<specific string>%'
Roland
0 -
Thank you very much! It's very simple and works well! (I was lost at FilterExamples and SelectAttributes and didn't find the solution here...)Retegniw wrote:
Once you have set up a database connection (Tools > Manage Database Connections) you can use the "Read Database" operator and its query property to write an SQL query.
Roland0 -
Glad to help.
Roland0