[SOLVED]Problem with WriteCSV

New Altair Community Member
Updated by Jocelyn
Hi Forum,
I have a problem with "Write CSV" operator: I provide its input with a "Format Number" operator and set all "real" data types to integer. The format number operator works fine. But when I Write its result in a file by "Write CSV" operator, All of my "real" data are still in the form of "ex. 1.0", instead of "ex. 1" in the resulting csv file. Any one knows what is wrong here?
any idea would be appreciated.
I have a problem with "Write CSV" operator: I provide its input with a "Format Number" operator and set all "real" data types to integer. The format number operator works fine. But when I Write its result in a file by "Write CSV" operator, All of my "real" data are still in the form of "ex. 1.0", instead of "ex. 1" in the resulting csv file. Any one knows what is wrong here?
any idea would be appreciated.
Find more posts tagged with
Sort by:
1 - 6 of
61
Hi nice guy: Marius
I made a mistake by writing "ex. 0". I mean "for example":) Sorry for my poor English. So please do not consider the "ex" prefix Marius. Here is my process as you have requested:
I made a mistake by writing "ex. 0". I mean "for example":) Sorry for my poor English. So please do not consider the "ex" prefix Marius. Here is my process as you have requested:
Any help would be appreciated.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.006">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="read_csv" compatibility="5.2.006" expanded="true" height="60" name="Read CSV" width="90" x="45" y="75">
<parameter key="csv_file" value="C:\Users\Qodmanan\Desktop\test.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_for_quotes" value="\"/>
<parameter key="skip_comments" value="false"/>
<parameter key="comment_characters" value="#"/>
<parameter key="parse_numbers" value="true"/>
<parameter key="decimal_character" value="."/>
<parameter key="grouped_digits" value="false"/>
<parameter key="grouping_character" value=","/>
<parameter key="date_format" value=""/>
<parameter key="first_row_as_names" value="false"/>
<list key="annotations"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="encoding" value="windows-1252"/>
<list key="data_set_meta_data_information">
<parameter key="0" value="att1.true.integer.attribute"/>
<parameter key="1" value="att2.true.integer.attribute"/>
<parameter key="2" value="att3.true.integer.attribute"/>
<parameter key="3" value="att4.true.polynominal.label"/>
</list>
<parameter key="read_not_matching_values_as_missings" value="true"/>
<parameter key="datamanagement" value="short_array"/>
</operator>
</process>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.006">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="write_csv" compatibility="5.2.006" expanded="true" height="76" name="Write CSV" width="90" x="581" y="75">
<parameter key="csv_file" value="C:\train\TruncatedData\StratifiedSampledData_0.1Ratio\sampled4.csv"/>
<parameter key="column_separator" value=","/>
<parameter key="write_attribute_names" value="false"/>
<parameter key="quote_nominal_values" value="false"/>
<parameter key="format_date_attributes" value="false"/>
<parameter key="encoding" value="SYSTEM"/>
</operator>
</process>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.006">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="write_file" compatibility="5.2.006" expanded="true" height="60" name="Write File" width="90" x="715" y="120">
<parameter key="resource_type" value="file"/>
<parameter key="filename" value="C:\Users\Qodmanan\Desktop\testtttt.csv"/>
<parameter key="mime_type" value="application/octet-stream"/>
</operator>
</process>
Hi, Sorry for the inconvenience,
here is the code:
here is the code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.006">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.2.006" expanded="true" name="Process">
<process expanded="true" height="424" width="705">
<operator activated="true" class="retrieve" compatibility="5.2.006" expanded="true" height="60" name="Retrieve" width="90" x="45" y="75">
<parameter key="repository_entry" value="//Samples/data/Golf"/>
</operator>
<operator activated="true" class="sample_stratified" compatibility="5.2.006" expanded="true" height="76" name="Sample (Stratified)" width="90" x="180" y="30">
<parameter key="sample" value="relative"/>
<parameter key="use_local_random_seed" value="true"/>
<parameter key="local_random_seed" value="2222"/>
</operator>
<operator activated="true" class="remove_useless_attributes" compatibility="5.2.006" expanded="true" height="76" name="Remove Useless Attributes" width="90" x="315" y="30"/>
<operator activated="true" class="format_numbers" compatibility="5.2.006" expanded="true" height="76" name="Format Numbers" width="90" x="450" y="30">
<parameter key="attribute_filter_type" value="value_type"/>
<parameter key="value_type" value="real"/>
<parameter key="include_special_attributes" value="true"/>
<parameter key="format_type" value="integer"/>
</operator>
<operator activated="true" class="write_csv" compatibility="5.2.006" expanded="true" height="76" name="Write CSV" width="90" x="585" y="30">
<parameter key="csv_file" value="C:\train\TruncatedData\StratifiedSampledData_0.1Ratio\sampled4.csv"/>
<parameter key="column_separator" value=","/>
<parameter key="write_attribute_names" value="false"/>
<parameter key="quote_nominal_values" value="false"/>
<parameter key="format_date_attributes" value="false"/>
</operator>
<operator activated="true" class="write_file" compatibility="5.2.006" expanded="true" height="60" name="Write File" width="90" x="581" y="165">
<parameter key="filename" value="C:\train\TruncatedData\sample5"/>
</operator>
<connect from_op="Retrieve" from_port="output" to_op="Sample (Stratified)" to_port="example set input"/>
<connect from_op="Sample (Stratified)" from_port="example set output" to_op="Remove Useless Attributes" to_port="example set input"/>
<connect from_op="Remove Useless Attributes" from_port="example set output" to_op="Format Numbers" to_port="example set input"/>
<connect from_op="Format Numbers" from_port="example set output" to_op="Write CSV" to_port="input"/>
<connect from_op="Write CSV" from_port="file" to_op="Write File" to_port="file"/>
<connect from_op="Write File" from_port="file" 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>
Hi,
as Marius stated all numerical values are written as real values. Thus you have to insert a Numerical to Polynominal Operator. Take a look here:
Nils
as Marius stated all numerical values are written as real values. Thus you have to insert a Numerical to Polynominal Operator. Take a look here:
Best,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.007">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.2.007" expanded="true" name="Process">
<process expanded="true" height="424" width="705">
<operator activated="true" class="retrieve" compatibility="5.2.007" expanded="true" height="60" name="Retrieve" width="90" x="45" y="75">
<parameter key="repository_entry" value="//Samples/data/Golf"/>
</operator>
<operator activated="true" class="sample_stratified" compatibility="5.2.007" expanded="true" height="76" name="Sample (Stratified)" width="90" x="180" y="30">
<parameter key="sample" value="relative"/>
<parameter key="use_local_random_seed" value="true"/>
<parameter key="local_random_seed" value="2222"/>
</operator>
<operator activated="true" class="remove_useless_attributes" compatibility="5.2.007" expanded="true" height="76" name="Remove Useless Attributes" width="90" x="315" y="30"/>
<operator activated="true" class="format_numbers" compatibility="5.2.007" expanded="true" height="76" name="Format Numbers" width="90" x="450" y="30">
<parameter key="attribute_filter_type" value="value_type"/>
<parameter key="value_type" value="real"/>
<parameter key="include_special_attributes" value="true"/>
<parameter key="format_type" value="integer"/>
</operator>
<operator activated="true" class="numerical_to_polynominal" compatibility="5.2.007" expanded="true" height="76" name="Numerical to Polynominal" width="90" x="447" y="165">
<parameter key="attribute_filter_type" value="value_type"/>
<parameter key="value_type" value="integer"/>
</operator>
<operator activated="true" class="write_csv" compatibility="5.2.007" expanded="true" height="76" name="Write CSV" width="90" x="581" y="30">
<parameter key="csv_file" value="C:\train\TruncatedData\StratifiedSampledData_0.1Ratio\sampled4.csv"/>
<parameter key="column_separator" value=","/>
<parameter key="write_attribute_names" value="false"/>
<parameter key="quote_nominal_values" value="false"/>
<parameter key="format_date_attributes" value="false"/>
</operator>
<operator activated="true" class="write_file" compatibility="5.2.007" expanded="true" height="60" name="Write File" width="90" x="581" y="165">
<parameter key="filename" value="C:\Users\nwoehler\Desktop\sample5"/>
</operator>
<connect from_op="Retrieve" from_port="output" to_op="Sample (Stratified)" to_port="example set input"/>
<connect from_op="Sample (Stratified)" from_port="example set output" to_op="Remove Useless Attributes" to_port="example set input"/>
<connect from_op="Remove Useless Attributes" from_port="example set output" to_op="Format Numbers" to_port="example set input"/>
<connect from_op="Format Numbers" from_port="example set output" to_op="Numerical to Polynominal" to_port="example set input"/>
<connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Write CSV" to_port="input"/>
<connect from_op="Write CSV" from_port="file" to_op="Write File" to_port="file"/>
<connect from_op="Write File" from_port="file" 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>
Nils
Best, Marius