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
select attribute and save
platanas20
Member Posts: 22 Contributor II
Hello to everyone,
I want to save in differents txt files some comments which are in an excel file. I use the operator "read excel" , "select attribute" , "write as a text" .
My code is:
Thanks!!!
I want to save in differents txt files some comments which are in an excel file. I use the operator "read excel" , "select attribute" , "write as a text" .
My code is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>As a result i take one txt file with all the comments.What i must to do to save the comments in differents files?
<process version="5.1.008">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process">
<parameter key="encoding" value="UTF-8"/>
<parameter key="parallelize_main_process" value="true"/>
<process expanded="true" height="280" width="547">
<operator activated="true" class="read_excel" compatibility="5.1.008" expanded="true" height="60" name="Read Excel" width="90" x="65" y="66">
<parameter key="excel_file" value="C:\Users\elenious\Desktop\diplomatiki\newresults\ypes_comments_98.xls"/>
<parameter key="imported_cell_range" value="G1:G1362"/>
<parameter key="first_row_as_names" value="false"/>
<list key="annotations">
<parameter key="0" value="Name"/>
</list>
<list key="data_set_meta_data_information">
<parameter key="0" value="Σχόλιο.true.polynominal.attribute"/>
</list>
</operator>
<operator activated="true" class="select_attributes" compatibility="5.1.008" expanded="true" height="76" name="Select Attributes" width="90" x="246" y="75">
<parameter key="attribute_filter_type" value="single"/>
<parameter key="attribute" value="Σχόλιο"/>
<parameter key="attributes" value="|Σχόλιο"/>
<parameter key="value_type" value="text"/>
<parameter key="include_special_attributes" value="true"/>
</operator>
<operator activated="true" class="write_as_text" compatibility="5.1.008" expanded="true" height="76" name="Write as Text" width="90" x="447" y="210">
<parameter key="result_file" value="C:\Users\elenious\Desktop\asbeo comte\comments_%{a}.txt"/>
<parameter key="encoding" value="UTF-8"/>
</operator>
<connect from_op="Read Excel" from_port="output" to_op="Select Attributes" to_port="example set input"/>
<connect from_op="Select Attributes" from_port="example set output" to_op="Write as Text" to_port="input 1"/>
<connect from_op="Write as Text" from_port="input 1" 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>
Thanks!!!
0
Answers
if each comment is a single line in your excel file, you can easily use the "Loop Examples" operator and put the file writing inside. This allows you to write one file per example.
I fear that some of your settings are messed up, but this should show the relevant changes: Regards
Matthias
Yes each comment is a single line in my excel file, this code works fine (it creates txt files), but in txts files saved this
"31.08.2011 20:13:24 Results of ResultWriter 'Write as Text' [1]:
31.08.2011 20:13:24 SplittedExampleSet:
1 examples,
1 regular attributes,
no special attributes"
What i must to do to save my comments?
Thanks
I never used "Write as Text" and don't know what it should do. It seems to deliver only the description of the example set.
I guess you should be able to use "Write Special Format" instead, but I am also not familiar with this operator. I used macros and document operators to write contents of single attributes to files earlier.
Something like the following should work: Best regards
Matthias
Hi Matthias,
Yes "Extract Macro" works right!!!!!
Thank you so much!!!!! ;D ;D ;D
Hi again,
i have one question, how can the txts files have encoding UTF-8 ???
Thanks
this is not possible at the moment with "Write Document", since this operator uses the Java class FileWriter. This always uses the system's default encoding. So the encoding will depend on the operating system used.
If you are familiar with Java programming, you should be able to replace this writer with an alternative, that let's you specify the encoding to use. If not, you might post this as feature request and hope this will be implemented in the future. Since this is a really simple task once you are familar with RapidMiner coding, I might also change this for you. But since I'm really close to the deadline for submitting my thesis, you would also have to wait about three weeks until I will have the time for changing this...
Regards
Matthias
I created a project in netbeans where i add the rapidminer operators exactly as the xml : But when i run it (via netbeans) ,it creates txt files which all contains only the first comment (the first row of excel). In RapidMiner it works fine. Does anyone know how can i solve it?