if else

Reem11
Reem11 New Altair Community Member
edited November 5 in Community Q&A
i need generate new Att based on  old Att if the old Att length is >= 3 delete the two last value else but the same value 

for example if the value is Yahya but it Yah
Tagged:

Answers

  • jwpfau
    jwpfau New Altair Community Member
    Hi Reem,

    i hope you figured it out by now, but here is an example for what you have described:
    <?xml version="1.0" encoding="UTF-8"?><process version="10.3.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="10.3.001" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="utility:create_exampleset" compatibility="10.3.001" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="34">
            <parameter key="generator_type" value="comma separated text"/>
            <parameter key="number_of_examples" value="100"/>
            <parameter key="use_stepsize" value="false"/>
            <list key="function_descriptions"/>
            <parameter key="add_id_attribute" value="false"/>
            <list key="numeric_series_configuration"/>
            <list key="date_series_configuration"/>
            <list key="date_series_configuration (interval)"/>
            <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
            <parameter key="time_zone" value="Europe/Berlin"/>
            <parameter key="input_csv_text" value="Att&#10;Yahya&#10;Jay&#10;Tu&#10;Magdalena"/>
            <parameter key="column_separator" value=","/>
            <parameter key="parse_all_as_nominal" value="false"/>
            <parameter key="decimal_point_character" value="."/>
            <parameter key="trim_attribute_names" value="true"/>
          </operator>
          <operator activated="true" class="blending:generate_columns" compatibility="10.3.001" expanded="true" height="82" name="Generate Attributes" width="90" x="447" y="34">
            <list key="function_descriptions">
              <parameter key="new Att" value="if(length(Att) &gt;= 3, cut(Att, 0, length(Att)-2), Att)"/>
            </list>
            <parameter key="keep_all_columns" value="true"/>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Generate Attributes" to_port="table input"/>
          <connect from_op="Generate Attributes" from_port="table 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>
    

    Greetings,
    Jonas