Options

How to cut a string or digit from right side

RPattelaRPattela Member Posts: 8 Contributor I
edited November 2018 in Help

Hello,

I tried in differnt ways to cut a a string or digit from right side but i m unable to get.

 For example I have a column A. I need five digits like column B. Please help me out

 

A B
220170002 70002
857203 57203
88986401 86401
96600 96600

 

 

Answers

  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,517 RM Data Scientist

    Hi,

     

    doesn't the suffix function in Generate Attributes do the job?

     

    ~Martin

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • Options
    JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 578 Unicorn

    Exactly as @mschmitz said above, but you might need to convert your integer on the left column into a nominal value first using str() or one of the RapidMiner operators.

     

    Here is a sample process.

     

    <?xml version="1.0" encoding="UTF-8"?><process version="7.3.000">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.3.000" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="text:create_document" compatibility="7.3.000" expanded="true" height="68" name="Create Document" width="90" x="45" y="136">
    <parameter key="text" value="220170002&#10;857203&#10;88986401&#10;96600"/>
    </operator>
    <operator activated="true" class="text:write_document" compatibility="7.3.000" expanded="true" height="82" name="Write Document" width="90" x="179" y="136"/>
    <operator activated="true" class="read_csv" compatibility="7.3.000" expanded="true" height="68" name="Read CSV" width="90" x="313" y="136">
    <parameter key="first_row_as_names" value="false"/>
    <list key="annotations"/>
    <list key="data_set_meta_data_information"/>
    </operator>
    <operator activated="true" class="generate_attributes" compatibility="7.3.000" expanded="true" height="82" name="Generate Attributes" width="90" x="447" y="136">
    <list key="function_descriptions">
    <parameter key="suffix_example" value="suffix(str(att1),5)"/>
    </list>
    <description align="center" color="transparent" colored="false" width="126">Note the use of str() to change the integer value into a nominal value before suffix.</description>
    </operator>
    <connect from_op="Create Document" from_port="output" to_op="Write Document" to_port="document"/>
    <connect from_op="Write Document" from_port="file" to_op="Read CSV" to_port="file"/>
    <connect from_op="Read CSV" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
    <connect from_op="Generate 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>
Sign In or Register to comment.