🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Easiest way to remove "count" in front of attribute name

User: "jhiKl"
New Altair Community Member
Updated by Jocelyn
Hello! is there a way where I can remove the word count in front of the name of the attribute all at once?
What I have is a lot of
attribute name : count (prod_name)_sunglasses

What I would like to have
attribute name: sunglasses

Find more posts tagged with

Sort by:
1 - 8 of 81
    User: "hbajpai"
    New Altair Community Member
    Accepted Answer
    Hey @jhiKl,

    You can use rename by replacing operator. Let's say this is the input:


    The output will be:



    The XML code for the same process is:

    <?xml version="1.0" encoding="UTF-8"?><process version="9.6.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.6.000" 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="generate_data" compatibility="9.6.000" expanded="true" height="68" name="Generate Data" width="90" x="581" y="34">
            <parameter key="target_function" value="random"/>
            <parameter key="number_examples" value="100"/>
            <parameter key="number_of_attributes" value="5"/>
            <parameter key="attributes_lower_bound" value="-10.0"/>
            <parameter key="attributes_upper_bound" value="10.0"/>
            <parameter key="gaussian_standard_deviation" value="10.0"/>
            <parameter key="largest_radius" value="10.0"/>
            <parameter key="use_local_random_seed" value="false"/>
            <parameter key="local_random_seed" value="1992"/>
            <parameter key="datamanagement" value="double_array"/>
            <parameter key="data_management" value="auto"/>
          </operator>
          <operator activated="true" breakpoints="after" class="rename" compatibility="9.6.000" expanded="true" height="82" name="Rename" width="90" x="715" y="34">
            <parameter key="old_name" value="att1"/>
            <parameter key="new_name" value="count (prod_name)_sunglasses"/>
            <list key="rename_additional_attributes">
              <parameter key="att2" value="count (prod_name)_rayban"/>
            </list>
          </operator>
          <operator activated="true" class="subprocess" compatibility="9.6.000" expanded="true" height="82" name="Rename by replacing block" width="90" x="916" y="34">
            <process expanded="true">
              <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="45" y="34">
                <parameter key="attribute_filter_type" value="subset"/>
                <parameter key="attribute" value=""/>
                <parameter key="attributes" value="count (prod_name)_rayban|count (prod_name)_sunglasses"/>
                <parameter key="use_except_expression" value="false"/>
                <parameter key="value_type" value="attribute_value"/>
                <parameter key="use_value_type_exception" value="false"/>
                <parameter key="except_value_type" value="time"/>
                <parameter key="block_type" value="attribute_block"/>
                <parameter key="use_block_type_exception" value="false"/>
                <parameter key="except_block_type" value="value_matrix_row_start"/>
                <parameter key="invert_selection" value="false"/>
                <parameter key="include_special_attributes" value="false"/>
                <parameter key="replace_what" value="count"/>
                <parameter key="replace_by" value=""/>
              </operator>
              <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing (2)" width="90" x="179" y="34">
                <parameter key="attribute_filter_type" value="subset"/>
                <parameter key="attribute" value=""/>
                <parameter key="attributes" value=" (prod_name)_rayban| (prod_name)_sunglasses"/>
                <parameter key="use_except_expression" value="false"/>
                <parameter key="value_type" value="attribute_value"/>
                <parameter key="use_value_type_exception" value="false"/>
                <parameter key="except_value_type" value="time"/>
                <parameter key="block_type" value="attribute_block"/>
                <parameter key="use_block_type_exception" value="false"/>
                <parameter key="except_block_type" value="value_matrix_row_start"/>
                <parameter key="invert_selection" value="false"/>
                <parameter key="include_special_attributes" value="false"/>
                <parameter key="replace_what" value="[_()]"/>
                <parameter key="replace_by" value=""/>
              </operator>
              <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing (3)" width="90" x="313" y="34">
                <parameter key="attribute_filter_type" value="subset"/>
                <parameter key="attribute" value=""/>
                <parameter key="attributes" value=" prodnamerayban| prodnamesunglasses"/>
                <parameter key="use_except_expression" value="false"/>
                <parameter key="value_type" value="attribute_value"/>
                <parameter key="use_value_type_exception" value="false"/>
                <parameter key="except_value_type" value="time"/>
                <parameter key="block_type" value="attribute_block"/>
                <parameter key="use_block_type_exception" value="false"/>
                <parameter key="except_block_type" value="value_matrix_row_start"/>
                <parameter key="invert_selection" value="false"/>
                <parameter key="include_special_attributes" value="false"/>
                <parameter key="replace_what" value="prodname"/>
              </operator>
              <connect from_port="in 1" to_op="Rename by Replacing" to_port="example set input"/>
              <connect from_op="Rename by Replacing" from_port="example set output" to_op="Rename by Replacing (2)" to_port="example set input"/>
              <connect from_op="Rename by Replacing (2)" from_port="example set output" to_op="Rename by Replacing (3)" to_port="example set input"/>
              <connect from_op="Rename by Replacing (3)" from_port="example set output" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="source_in 2" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Rename" to_port="example set input"/>
          <connect from_op="Rename" from_port="example set output" to_op="Rename by replacing block" to_port="in 1"/>
          <connect from_op="Rename by replacing block" from_port="out 1" 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>
    


    User: "jhiKl"
    New Altair Community Member
    OP
    Updated by jhiKl
    hello thank you for responding quickly, how do I replace just a part of the column name? I tried rename by replacing operator but it doesn't work
    User: "hbajpai"
    New Altair Community Member
    If that part is consistent (For example: count) and does not have any special characters. You can substitute it by using replace what as count and leave replace by blank in the operator. Otherwise you can use regex formatting to replace.

    If you can share your XML I quickly try and send you updates process.
    User: "jhiKl"
    New Altair Community Member
    OP
    <?xml version="1.0" encoding="UTF-8"?><process version="9.6.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.6.000" 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="retrieve" compatibility="9.6.000" expanded="true" height="68" name="Retrieve JANMarketAnalysis1997" width="90" x="45" y="187">
            <parameter key="repository_entry" value="//IS210 Case Analysis/data/JANMarketAnalysis1997"/>
          </operator>
          <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="179" y="187">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="replace_what" value="\W"/>
          </operator>
          <connect from_op="Retrieve JANMarketAnalysis1997" from_port="output" to_op="Rename by Replacing" to_port="example set input"/>
          <connect from_op="Rename by Replacing" 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>


    User: "jhiKl"
    New Altair Community Member
    OP
    I don't know if this is the xml that you need, but hopefully it is. Do you know how to regex the "count(product_name)_" i'm still looking for the regex that shows the "exact match".
    User: "Marco_Barradas"
    Altair Employee
    Accepted Answer
    @jhiKl this is the regex you need 
    Let me explain 
    • .* matches all the characters before the (
    • \( escapes the "(" you are trying to find
    • (\w+) tells that you want to capture all the word characters \w+ until the next rule
    • Please notice the difference when you try to find a "(" =\(  from when you are trying to capture something () there is no use of \
    • \) tells the regex that it need to stop capturing when it finds a ")"
    .*\((\w+)\)
    and you need to put on the replace  the$1 makes reference to the capture group 
    $1
    User: "jhiKl"
    New Altair Community Member
    OP
    Updated by jhiKl
    Hello, I was able to do it thanks to you guys!

    Appreciatively,
    jhiKl
    User: "mantanz"
    New Altair Community Member
    In case the complete text count(product_name)_ needs to match exact, then regex will be count\(product_name\)_