Pages: [1]
  Print  
Author Topic: Order of Attributes in the CSV file  (Read 1087 times)
Shubha
Full Member
***
Posts: 141


« on: June 10, 2009, 11:51:09 AM »

Hi,

Code:
<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
        <parameter key="target_function" value="random"/>
        <parameter key="number_examples" value="10"/>
    </operator>
    <operator name="ChangeAttributeRole" class="ChangeAttributeRole" activated="no">
        <parameter key="name" value="label"/>
    </operator>
    <operator name="CSVExampleSetWriter" class="CSVExampleSetWriter" breakpoints="before">
        <parameter key="csv_file" value="check.csv"/>
        <parameter key="column_separator" value=","/>
    </operator>
</operator>

I want to write the data generated to a CSV file. While writing, the special attribute, 'label' is written as the last attribute in the CSV file, check.csv. But I need to write the data as the order appears in the Exampleset like (label,att1,att2,att3,att4,att5). Any hints on this?

Thanks and Regards,
Shubha
Logged
haddock
Hero Member
*****
Posts: 853



WWW
« Reply #1 on: June 10, 2009, 02:20:14 PM »

Hi Shubha,

You get that column order control using the special format option on the ExampleSetWriter, like this..


Code:
<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
        <parameter key="target_function" value="random"/>
    </operator>
    <operator name="IdTagging" class="IdTagging">
    </operator>
    <operator name="ExampleSetWriter" class="ExampleSetWriter">
        <parameter key="example_set_file" value="C:\Users\CJFP\Documents\rm_workspace\bla.dat"/>
        <parameter key="format" value="special_format"/>
        <parameter key="special_format" value="$l,$i,$a[,]$n"/>
    </operator>
    <operator name="CSVExampleSource" class="CSVExampleSource">
        <parameter key="filename" value="C:\Users\CJFP\Documents\rm_workspace\bla.dat"/>
        <parameter key="read_attribute_names" value="false"/>
    </operator>
</operator>
Logged

Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?

T.S.Eliot ~ Choruses from the Rock 1934
Shubha
Full Member
***
Posts: 141


« Reply #2 on: June 10, 2009, 02:29:45 PM »

Wonderful...

Thanks
Logged
Pages: [1]
  Print  
 
Jump to: