The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Prefixing the Attribute names

ShubhaShubha Member Posts: 139 Maven
edited November 2018 in Help
Hi,

I want to prefix certain attribute names with a particular string. Below I have a generated an example data....
<operator name="Root" class="Process" expanded="yes">
    <operator name="Generate Suitable Data" class="OperatorChain" expanded="yes">
        <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
            <parameter key="target_function" value="sum"/>
            <parameter key="number_examples" value="10"/>
        </operator>
        <operator name="ChangeAttributeName" class="ChangeAttributeName">
            <parameter key="old_name" value="att1"/>
            <parameter key="new_name" value="A"/>
        </operator>
        <operator name="ChangeAttributeName (2)" class="ChangeAttributeName">
            <parameter key="old_name" value="att2"/>
            <parameter key="new_name" value="B"/>
        </operator>
        <operator name="ChangeAttributeName (3)" class="ChangeAttributeName">
            <parameter key="old_name" value="att3"/>
            <parameter key="new_name" value="H"/>
        </operator>
        <operator name="ChangeAttributeName (4)" class="ChangeAttributeName">
            <parameter key="old_name" value="att4"/>
            <parameter key="new_name" value="Y"/>
        </operator>
        <operator name="ChangeAttributeName (5)" class="ChangeAttributeName">
            <parameter key="old_name" value="att5"/>
            <parameter key="new_name" value="M"/>
        </operator>
    </operator>
</operator>
Now in the above data, I need to Prefix the attributes A, B, H, Y and M with the string, "Var_". So, my new changed attribute names are now, Var_A, Var_B, Var_H, Var_Y and Var_M. Note: The original variables A, B, H.... can be a mix of any data type, not always real.

I tried with changing attribute names and related operators, but did not get it... How do i perform this?

Thanks, Shubha

Answers

  • ShubhaShubha Member Posts: 139 Maven
    Hi, got that done by adding the below code:
        <operator name="ChangeAttributeNamesReplace" class="ChangeAttributeNamesReplace">
            <parameter key="replace_what" value="^"/>
            <parameter key="replace_by" value="Var_"/>
        </operator>
Sign In or Register to comment.