"Write to Text problem"
mavi16ab
New Altair Community Member
So I have a Text file that I read, and then continue to do some filtering on. At the end of the process, I would like to create a .txt file with all the text from my Example Set. I use the Write to Text operator, but it only writes the amount of examples in the .txt file it creates. Am I using it wrong?
Code for my process:
Code for my process:
<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process">
<parameter key="logverbosity" value="init"/>
<parameter key="random_seed" value="2001"/>
<parameter key="send_mail" value="never"/>
<parameter key="notification_email" value=""/>
<parameter key="process_duration_for_mail" value="30"/>
<parameter key="encoding" value="SYSTEM"/>
<process expanded="true">
<operator activated="true" class="read_csv" compatibility="9.2.000" expanded="true" height="68" name="Read CSV" width="90" x="45" y="34">
<parameter key="csv_file" value="/Users/MathiasVildbrad/Desktop/new_new_converted.txt"/>
<parameter key="column_separators" value=","/>
<parameter key="trim_lines" value="false"/>
<parameter key="use_quotes" value="true"/>
<parameter key="quotes_character" value="""/>
<parameter key="escape_character" value="\"/>
<parameter key="skip_comments" value="true"/>
<parameter key="comment_characters" value="#"/>
<parameter key="starting_row" value="1"/>
<parameter key="parse_numbers" value="true"/>
<parameter key="decimal_character" value="."/>
<parameter key="grouped_digits" value="false"/>
<parameter key="grouping_character" value=","/>
<parameter key="infinity_representation" value=""/>
<parameter key="date_format" value=""/>
<parameter key="first_row_as_names" value="true"/>
<list key="annotations"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="encoding" value="UTF-8"/>
<parameter key="read_all_values_as_polynominal" value="false"/>
<list key="data_set_meta_data_information">
<parameter key="0" value="Text.true.polynominal.attribute"/>
</list>
<parameter key="read_not_matching_values_as_missings" value="false"/>
<parameter key="datamanagement" value="double_array"/>
<parameter key="data_management" value="auto"/>
</operator>
<operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Deleted & Removed" width="90" x="45" y="136">
<parameter key="parameter_expression" value=""/>
<parameter key="condition_class" value="custom_filters"/>
<parameter key="invert_filter" value="true"/>
<list key="filters_list">
<parameter key="filters_entry_key" value="Text.equals.[deleted]"/>
<parameter key="filters_entry_key" value="Text.equals.[removed]"/>
</list>
<parameter key="filters_logic_and" value="false"/>
<parameter key="filters_check_metadata" value="true"/>
</operator>
<operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Remove links" width="90" x="45" y="289">
<parameter key="attribute_filter_type" value="all"/>
<parameter key="attribute" value=""/>
<parameter key="attributes" value=""/>
<parameter key="use_except_expression" value="false"/>
<parameter key="value_type" value="nominal"/>
<parameter key="use_value_type_exception" value="false"/>
<parameter key="except_value_type" value="file_path"/>
<parameter key="block_type" value="single_value"/>
<parameter key="use_block_type_exception" value="false"/>
<parameter key="except_block_type" value="single_value"/>
<parameter key="invert_selection" value="false"/>
<parameter key="include_special_attributes" value="false"/>
<parameter key="replace_what" value="(https?|http)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"/>
</operator>
<operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace Special Characthers" width="90" x="45" y="391">
<parameter key="attribute_filter_type" value="all"/>
<parameter key="attribute" value=""/>
<parameter key="attributes" value=""/>
<parameter key="use_except_expression" value="false"/>
<parameter key="value_type" value="nominal"/>
<parameter key="use_value_type_exception" value="false"/>
<parameter key="except_value_type" value="file_path"/>
<parameter key="block_type" value="single_value"/>
<parameter key="use_block_type_exception" value="false"/>
<parameter key="except_block_type" value="single_value"/>
<parameter key="invert_selection" value="false"/>
<parameter key="include_special_attributes" value="false"/>
<parameter key="replace_what" value="[-!"#$%&'()*+,./:;<=>?@\[\\\]_`{|}~§€^]"/>
</operator>
<operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Remove empty" width="90" x="179" y="34">
<parameter key="parameter_expression" value=""/>
<parameter key="condition_class" value="custom_filters"/>
<parameter key="invert_filter" value="false"/>
<list key="filters_list">
<parameter key="filters_entry_key" value="Text.is_not_missing."/>
</list>
<parameter key="filters_logic_and" value="true"/>
<parameter key="filters_check_metadata" value="true"/>
</operator>
<operator activated="true" class="nominal_to_text" compatibility="9.2.000" expanded="true" height="82" name="Nominal to Text" width="90" x="313" y="34">
<parameter key="attribute_filter_type" value="all"/>
<parameter key="attribute" value=""/>
<parameter key="attributes" value=""/>
<parameter key="use_except_expression" value="false"/>
<parameter key="value_type" value="nominal"/>
<parameter key="use_value_type_exception" value="false"/>
<parameter key="except_value_type" value="file_path"/>
<parameter key="block_type" value="single_value"/>
<parameter key="use_block_type_exception" value="false"/>
<parameter key="except_block_type" value="single_value"/>
<parameter key="invert_selection" value="false"/>
<parameter key="include_special_attributes" value="false"/>
</operator>
<operator activated="true" class="write_as_text" compatibility="9.2.000" expanded="true" height="103" name="Write as Text" width="90" x="447" y="34">
<parameter key="result_file" value="/Users/MathiasVildbrad/Desktop/nice.txt"/>
<parameter key="encoding" value="UTF-8"/>
</operator>
<connect from_op="Read CSV" from_port="output" to_op="Deleted & Removed" to_port="example set input"/>
<connect from_op="Deleted & Removed" from_port="example set output" to_op="Remove links" to_port="example set input"/>
<connect from_op="Remove links" from_port="example set output" to_op="Replace Special Characthers" to_port="example set input"/>
<connect from_op="Replace Special Characthers" from_port="example set output" to_op="Remove empty" to_port="example set input"/>
<connect from_op="Remove empty" from_port="example set output" to_op="Nominal to Text" to_port="example set input"/>
<connect from_op="Nominal to Text" from_port="example set output" to_op="Write as Text" to_port="input 1"/>
<connect from_op="Nominal to Text" from_port="original" to_op="Write as Text" to_port="input 2"/>
<connect from_op="Write as Text" from_port="input 1" to_port="result 1"/>
<connect from_op="Write as Text" from_port="input 2" to_port="result 2"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
<portSpacing port="sink_result 3" spacing="0"/>
</process>
</operator>
</process>
Tagged:
0
Answers
-
Try using the Write Document operator. You will need to group the collect and change the data to documents for it to work. Also when you write the extension for the file in the Write Document operator make sure you remove the ".*" at the end of the file name.1
-
<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"> <parameter key="logverbosity" value="init"/> <parameter key="random_seed" value="2001"/> <parameter key="send_mail" value="never"/> <parameter key="notification_email" value=""/> <parameter key="process_duration_for_mail" value="30"/> <parameter key="encoding" value="SYSTEM"/> <process expanded="true"> <operator activated="true" class="read_csv" compatibility="9.2.000" expanded="true" height="68" name="Read CSV" width="90" x="45" y="34"> <parameter key="csv_file" value="/Users/robinmeisel/Desktop/'UP%20Feb 2019-02-04.csv"/> <parameter key="column_separators" value=","/> <parameter key="trim_lines" value="false"/> <parameter key="use_quotes" value="true"/> <parameter key="quotes_character" value="""/> <parameter key="escape_character" value="\"/> <parameter key="skip_comments" value="true"/> <parameter key="comment_characters" value="#"/> <parameter key="starting_row" value="1"/> <parameter key="parse_numbers" value="true"/> <parameter key="decimal_character" value="."/> <parameter key="grouped_digits" value="false"/> <parameter key="grouping_character" value=","/> <parameter key="infinity_representation" value=""/> <parameter key="date_format" value=""/> <parameter key="first_row_as_names" value="true"/> <list key="annotations"/> <parameter key="time_zone" value="SYSTEM"/> <parameter key="locale" value="English (United States)"/> <parameter key="encoding" value="UTF-8"/> <parameter key="read_all_values_as_polynominal" value="false"/> <list key="data_set_meta_data_information"> <parameter key="0" value="Text.true.polynominal.attribute"/> </list> <parameter key="read_not_matching_values_as_missings" value="false"/> <parameter key="datamanagement" value="double_array"/> <parameter key="data_management" value="auto"/> </operator> <operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Deleted & Removed" width="90" x="45" y="136"> <parameter key="parameter_expression" value=""/> <parameter key="condition_class" value="custom_filters"/> <parameter key="invert_filter" value="true"/> <list key="filters_list"> <parameter key="filters_entry_key" value="Text.equals.[deleted]"/> <parameter key="filters_entry_key" value="Text.equals.[removed]"/> </list> <parameter key="filters_logic_and" value="false"/> <parameter key="filters_check_metadata" value="true"/> </operator> <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Remove links" width="90" x="45" y="289"> <parameter key="attribute_filter_type" value="all"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=""/> <parameter key="use_except_expression" value="false"/> <parameter key="value_type" value="nominal"/> <parameter key="use_value_type_exception" value="false"/> <parameter key="except_value_type" value="file_path"/> <parameter key="block_type" value="single_value"/> <parameter key="use_block_type_exception" value="false"/> <parameter key="except_block_type" value="single_value"/> <parameter key="invert_selection" value="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="replace_what" value="(https?|http)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"/> </operator> <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace Special Characthers" width="90" x="45" y="391"> <parameter key="attribute_filter_type" value="all"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=""/> <parameter key="use_except_expression" value="false"/> <parameter key="value_type" value="nominal"/> <parameter key="use_value_type_exception" value="false"/> <parameter key="except_value_type" value="file_path"/> <parameter key="block_type" value="single_value"/> <parameter key="use_block_type_exception" value="false"/> <parameter key="except_block_type" value="single_value"/> <parameter key="invert_selection" value="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="replace_what" value="[-!"#$%&'()*+,./:;<=>?@\[\\\]_`{|}~§€^]"/> </operator> <operator activated="false" class="nominal_to_text" compatibility="9.2.000" expanded="true" height="82" name="Nominal to Text" width="90" x="313" y="136"> <parameter key="attribute_filter_type" value="all"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=""/> <parameter key="use_except_expression" value="false"/> <parameter key="value_type" value="nominal"/> <parameter key="use_value_type_exception" value="false"/> <parameter key="except_value_type" value="file_path"/> <parameter key="block_type" value="single_value"/> <parameter key="use_block_type_exception" value="false"/> <parameter key="except_block_type" value="single_value"/> <parameter key="invert_selection" value="false"/> <parameter key="include_special_attributes" value="false"/> </operator> <operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Remove empty" width="90" x="313" y="34"> <parameter key="parameter_expression" value=""/> <parameter key="condition_class" value="custom_filters"/> <parameter key="invert_filter" value="false"/> <list key="filters_list"> <parameter key="filters_entry_key" value="Text.is_not_missing."/> </list> <parameter key="filters_logic_and" value="true"/> <parameter key="filters_check_metadata" value="true"/> </operator> <operator activated="true" class="append" compatibility="9.2.000" expanded="true" height="82" name="Append" width="90" x="447" y="34"> <parameter key="datamanagement" value="double_array"/> <parameter key="data_management" value="auto"/> <parameter key="merge_type" value="all"/> </operator> <operator activated="true" class="write_csv" compatibility="9.2.000" expanded="true" height="82" name="Write CSV" width="90" x="581" y="34"> <parameter key="column_separator" value=";"/> <parameter key="write_attribute_names" value="true"/> <parameter key="quote_nominal_values" value="true"/> <parameter key="format_date_attributes" value="true"/> <parameter key="append_to_file" value="false"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="text:read_document" compatibility="8.1.000" expanded="true" height="68" name="Read Document" width="90" x="715" y="34"> <parameter key="extract_text_only" value="true"/> <parameter key="use_file_extension_as_type" value="true"/> <parameter key="content_type" value="txt"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="text:write_document" compatibility="8.1.000" expanded="true" height="82" name="Write Document" width="90" x="849" y="34"> <parameter key="file" value="/Users/robinmeisel/Desktop/test.txt"/> <parameter key="overwrite" value="true"/> <parameter key="encoding" value="SYSTEM"/> </operator> <connect from_op="Read CSV" from_port="output" to_op="Deleted & Removed" to_port="example set input"/> <connect from_op="Deleted & Removed" from_port="example set output" to_op="Remove links" to_port="example set input"/> <connect from_op="Remove links" from_port="example set output" to_op="Replace Special Characthers" to_port="example set input"/> <connect from_op="Replace Special Characthers" from_port="example set output" to_op="Remove empty" to_port="example set input"/> <connect from_op="Remove empty" from_port="example set output" to_op="Append" to_port="example set 1"/> <connect from_op="Append" from_port="merged set" to_op="Write CSV" to_port="input"/> <connect from_op="Write CSV" from_port="file" to_op="Read Document" to_port="file"/> <connect from_op="Read Document" from_port="output" to_op="Write Document" to_port="document"/> <connect from_op="Write Document" from_port="document" 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>
2 -
Also for inserting code in your comments
1