Generating new line inside of Generate Data operator

robin
New Altair Community Member
We currently generate text that is parsed into an XML for third party software. This software does not follow the conventions for line breaks and utilised the characters inside of the text field to split the lines.
We need to generate the following:
Get what
you want
When using the generate data operator and then the extract document operator the above gets turned into:
Get what you want
(There are two spaces (Hex: 20 20) instead of a line break (Hex: 0D 0A))
How do I correctly generate the line break using this operator?
We need to generate the following:
Get what
you want
When using the generate data operator and then the extract document operator the above gets turned into:
Get what you want
(There are two spaces (Hex: 20 20) instead of a line break (Hex: 0D 0A))
How do I correctly generate the line break using this operator?
<?xml version="1.0" encoding="UTF-8"?><process version="8.2.000"> <operator activated="true" class="generate_data_user_specification" compatibility="8.2.000" expanded="true" height="68" name="Generate Data by User Specification" width="90" x="715" y="595"> <list key="attribute_values"> <parameter key="1" value="("Get what you want")"/> </list> <list key="set_additional_roles"/> </operator> </process>
Tagged:
0
Best Answers
-
how about this?
<?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="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document" width="90" x="45" y="34"> <parameter key="text" value="Get what you want"/> <parameter key="add label" value="false"/> <parameter key="label_type" value="nominal"/> </operator> <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="179" y="34"> <parameter key="text_attribute" value="text"/> <parameter key="add_meta_information" value="false"/> <parameter key="datamanagement" value="double_sparse_array"/> <parameter key="data_management" value="auto"/> </operator> <operator activated="true" class="web:encode_urls" compatibility="9.0.000" expanded="true" height="82" name="Encode URLs" width="90" x="313" y="34"> <parameter key="url_attribute" value="text"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace" width="90" x="447" y="34"> <parameter key="attribute_filter_type" value="single"/> <parameter key="attribute" value="text"/> <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="[+][+]"/> <parameter key="replace_by" value="%0D%0A"/> </operator> <operator activated="true" class="web:decode_urls" compatibility="9.0.000" expanded="true" height="82" name="Decode URLs" width="90" x="581" y="34"> <parameter key="url_attribute" value="text"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="text:data_to_documents" compatibility="8.1.000" expanded="true" height="68" name="Data to Documents" width="90" x="715" y="34"> <parameter key="select_attributes_and_weights" value="false"/> <list key="specify_weights"/> </operator> <operator activated="true" class="text:combine_documents" compatibility="8.1.000" expanded="true" height="82" name="Combine Documents" width="90" x="849" y="34"/> <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/> <connect from_op="Documents to Data" from_port="example set" to_op="Encode URLs" to_port="example set input"/> <connect from_op="Encode URLs" from_port="example set output" to_op="Replace" to_port="example set input"/> <connect from_op="Replace" from_port="example set output" to_op="Decode URLs" to_port="example set input"/> <connect from_op="Decode URLs" from_port="example set output" to_op="Data to Documents" to_port="example set"/> <connect from_op="Data to Documents" from_port="documents" to_op="Combine Documents" to_port="documents 1"/> <connect from_op="Combine Documents" 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>
1 -
Hi,Less convoluted, but requires a short script is the process below. I was actually somewhat surprised that there is no way to add a new line character in any form (Java, Unicode, whatever) in the parameters. But then again: How could we without introducing a special symbol or some form of quoting? It would just be represented as a new line in the underlying XML otherwise...Anyway, here are some "solutions" although I freely admit that they are all a bit weirdBest,Ingo
<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="UTF-8"/><br> <process expanded="true"><br> <operator activated="true" class="utility:create_exampleset" compatibility="9.2.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34"><br> <parameter key="generator_type" value="attribute functions"/><br> <parameter key="number_of_examples" value="100"/><br> <parameter key="use_stepsize" value="false"/><br> <list key="function_descriptions"><br> <parameter key="att" value=""Get WhatNEWLINEYou Want""/><br> </list><br> <parameter key="add_id_attribute" value="false"/><br> <list key="numeric_series_configuration"/><br> <list key="date_series_configuration"/><br> <list key="date_series_configuration (interval)"/><br> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br> <parameter key="time_zone" value="SYSTEM"/><br> <parameter key="column_separator" value=","/><br> <parameter key="parse_all_as_nominal" value="false"/><br> <parameter key="decimal_point_character" value="."/><br> <parameter key="trim_attribute_names" value="true"/><br> </operator><br> <operator activated="true" class="execute_script" compatibility="9.2.000" expanded="true" height="82" name="Execute Script" width="90" x="179" y="34"><br> <parameter key="script" value="ExampleSet data = input[0]; Attribute att = data.getAttributes().get("att"); for (Example example : data) { 	example.setValue(att, example.getValueAsString(att).replaceAll("NEWLINE", "\r\n")); } return data;"/><br> <parameter key="standard_imports" value="true"/><br> </operator><br> <connect from_op="Create ExampleSet" from_port="output" to_op="Execute Script" to_port="input 1"/><br> <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process>
5
Answers
-
What I have been doing to date is going into the XML and changing the #10 to a #13 but that is not tenable when running on server.0
-
how about this?
<?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="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document" width="90" x="45" y="34"> <parameter key="text" value="Get what you want"/> <parameter key="add label" value="false"/> <parameter key="label_type" value="nominal"/> </operator> <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="179" y="34"> <parameter key="text_attribute" value="text"/> <parameter key="add_meta_information" value="false"/> <parameter key="datamanagement" value="double_sparse_array"/> <parameter key="data_management" value="auto"/> </operator> <operator activated="true" class="web:encode_urls" compatibility="9.0.000" expanded="true" height="82" name="Encode URLs" width="90" x="313" y="34"> <parameter key="url_attribute" value="text"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="replace" compatibility="9.2.000" expanded="true" height="82" name="Replace" width="90" x="447" y="34"> <parameter key="attribute_filter_type" value="single"/> <parameter key="attribute" value="text"/> <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="[+][+]"/> <parameter key="replace_by" value="%0D%0A"/> </operator> <operator activated="true" class="web:decode_urls" compatibility="9.0.000" expanded="true" height="82" name="Decode URLs" width="90" x="581" y="34"> <parameter key="url_attribute" value="text"/> <parameter key="encoding" value="SYSTEM"/> </operator> <operator activated="true" class="text:data_to_documents" compatibility="8.1.000" expanded="true" height="68" name="Data to Documents" width="90" x="715" y="34"> <parameter key="select_attributes_and_weights" value="false"/> <list key="specify_weights"/> </operator> <operator activated="true" class="text:combine_documents" compatibility="8.1.000" expanded="true" height="82" name="Combine Documents" width="90" x="849" y="34"/> <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/> <connect from_op="Documents to Data" from_port="example set" to_op="Encode URLs" to_port="example set input"/> <connect from_op="Encode URLs" from_port="example set output" to_op="Replace" to_port="example set input"/> <connect from_op="Replace" from_port="example set output" to_op="Decode URLs" to_port="example set input"/> <connect from_op="Decode URLs" from_port="example set output" to_op="Data to Documents" to_port="example set"/> <connect from_op="Data to Documents" from_port="documents" to_op="Combine Documents" to_port="documents 1"/> <connect from_op="Combine Documents" 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>
1 -
there is a very fine line between convoluted and clever1
-
Hi,Less convoluted, but requires a short script is the process below. I was actually somewhat surprised that there is no way to add a new line character in any form (Java, Unicode, whatever) in the parameters. But then again: How could we without introducing a special symbol or some form of quoting? It would just be represented as a new line in the underlying XML otherwise...Anyway, here are some "solutions" although I freely admit that they are all a bit weirdBest,Ingo
<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="UTF-8"/><br> <process expanded="true"><br> <operator activated="true" class="utility:create_exampleset" compatibility="9.2.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34"><br> <parameter key="generator_type" value="attribute functions"/><br> <parameter key="number_of_examples" value="100"/><br> <parameter key="use_stepsize" value="false"/><br> <list key="function_descriptions"><br> <parameter key="att" value=""Get WhatNEWLINEYou Want""/><br> </list><br> <parameter key="add_id_attribute" value="false"/><br> <list key="numeric_series_configuration"/><br> <list key="date_series_configuration"/><br> <list key="date_series_configuration (interval)"/><br> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br> <parameter key="time_zone" value="SYSTEM"/><br> <parameter key="column_separator" value=","/><br> <parameter key="parse_all_as_nominal" value="false"/><br> <parameter key="decimal_point_character" value="."/><br> <parameter key="trim_attribute_names" value="true"/><br> </operator><br> <operator activated="true" class="execute_script" compatibility="9.2.000" expanded="true" height="82" name="Execute Script" width="90" x="179" y="34"><br> <parameter key="script" value="ExampleSet data = input[0]; Attribute att = data.getAttributes().get("att"); for (Example example : data) { 	example.setValue(att, example.getValueAsString(att).replaceAll("NEWLINE", "\r\n")); } return data;"/><br> <parameter key="standard_imports" value="true"/><br> </operator><br> <connect from_op="Create ExampleSet" from_port="output" to_op="Execute Script" to_port="input 1"/><br> <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process>
5