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

[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.