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
Write out column headings for Write Special Format operator
text_miner
Member Posts: 11 Contributor II
Hi,
I'm trying to write out an ExampleSet as a tab-delimited file. I'm using the Write Special Format operator so that I can specify the order in which the attributes are written (column order). While I can write out the data just fine, I'm not sure how to also add column names to the output file. An example of what I want the output to look like is shown below along with a sample process that illustrates my problems.
Any help would be appreciate. Thanks!
Output desired:
[tt]
ID Att1 Att2 Label
1 1.2 1.4 True
2 2.3 3.2 False
...
[/tt]
Sample Process:
I'm trying to write out an ExampleSet as a tab-delimited file. I'm using the Write Special Format operator so that I can specify the order in which the attributes are written (column order). While I can write out the data just fine, I'm not sure how to also add column names to the output file. An example of what I want the output to look like is shown below along with a sample process that illustrates my problems.
Any help would be appreciate. Thanks!
Output desired:
[tt]
ID Att1 Att2 Label
1 1.2 1.4 True
2 2.3 3.2 False
...
[/tt]
Sample Process:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.0">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" expanded="true" name="Process">
<process expanded="true" height="952" width="900">
<operator activated="true" class="generate_data" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
<parameter key="number_of_attributes" value="2"/>
</operator>
<operator activated="true" class="generate_id" expanded="true" height="76" name="Generate ID" width="90" x="179" y="30"/>
<operator activated="true" class="write_special" expanded="true" height="60" name="Write Special Format" width="90" x="313" y="30">
<parameter key="example_set_file" value="C:\TEMP\temp.dat"/>
<parameter key="special_format" value="$i$t$v[att1]$t$v[att2]$t$l"/>
</operator>
<connect from_op="Generate Data" from_port="output" to_op="Generate ID" to_port="example set input"/>
<connect from_op="Generate ID" from_port="example set output" to_op="Write Special Format" to_port="input"/>
<connect from_op="Write Special Format" 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>
0
Answers
-Gagi
wouldn't it be a solution to transpose the example set and write out the first attribute containing the attribute names without ending with replacing the example separating newline character with a tab?
Then append the data by selecting the corresponding overwrite mode.
Anyway, you might add this as an feature request to the bugtracker.
Greetings,
Sebastian