Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

[SOLVED]create filename string from example value

fritmorefritmore Member Posts: 90 Contributor II
edited November 2018 in Help
Hi
cannot figure out how to make a file name (in my case for a csv write operator) from a particular attributes value in a particular example.
I tired macro such as Macroname=Attribname and than filename %{Macroname} but it doesnt work. It just names the file Attribname and not its particular Value.
(for selecting a single example I use loop so this is sorted out).

thanks for any help

Answers

  • Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi,

    you can try something like this:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.008">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
       <process expanded="true" height="235" width="480">
         <operator activated="true" class="retrieve" compatibility="5.2.008" expanded="true" height="60" name="Retrieve" width="90" x="86" y="71">
           <parameter key="repository_entry" value="//Samples/data/Iris"/>
         </operator>
         <operator activated="true" class="extract_macro" compatibility="5.2.008" expanded="true" height="60" name="Extract Macro" width="90" x="246" y="75">
           <parameter key="macro" value="fileName"/>
           <parameter key="macro_type" value="data_value"/>
           <parameter key="attribute_name" value="a1"/>
           <parameter key="example_index" value="1"/>
         </operator>
         <operator activated="true" class="write_csv" compatibility="5.2.008" expanded="true" height="76" name="Write CSV" width="90" x="380" y="75">
           <parameter key="csv_file" value="C:\%{fileName}"/>
         </operator>
         <connect from_op="Retrieve" from_port="output" to_op="Extract Macro" to_port="example set"/>
         <connect from_op="Extract Macro" from_port="example set" to_op="Write CSV" to_port="input"/>
         <connect from_op="Write CSV" from_port="through" 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>
    Best,
    Nils
  • fritmorefritmore Member Posts: 90 Contributor II
    Nils wrote:

    Hi,

    you can try something like this:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.008">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
       <process expanded="true" height="235" width="480">
         <operator activated="true" class="retrieve" compatibility="5.2.008" expanded="true" height="60" name="Retrieve" width="90" x="86" y="71">
           <parameter key="repository_entry" value="//Samples/data/Iris"/>
         </operator>
         <operator activated="true" class="extract_macro" compatibility="5.2.008" expanded="true" height="60" name="Extract Macro" width="90" x="246" y="75">
           <parameter key="macro" value="fileName"/>
           <parameter key="macro_type" value="data_value"/>
           <parameter key="attribute_name" value="a1"/>
           <parameter key="example_index" value="1"/>
         </operator>
         <operator activated="true" class="write_csv" compatibility="5.2.008" expanded="true" height="76" name="Write CSV" width="90" x="380" y="75">
           <parameter key="csv_file" value="C:\%{fileName}"/>
         </operator>
         <connect from_op="Retrieve" from_port="output" to_op="Extract Macro" to_port="example set"/>
         <connect from_op="Extract Macro" from_port="example set" to_op="Write CSV" to_port="input"/>
         <connect from_op="Write CSV" from_port="through" 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>
    Best,
    Nils
    thx Niels
    it works.

    Regarding your mention of writing a documentation for the operators in another thread I hope you add a detailed chapter on Macros ;)
Sign In or Register to comment.