[SOLVED] Transforming nominal data to numeric

UgoUgo Member Posts: 20 Contributor II
edited November 2018 in Help

I have a regular attribute that I set as polynominal, which contains text describing lengths.
The values for this attribute are things like (quotes not included): "1 cm",  "1,5 cm", etc.

I would like to convert the "decimal number" followed by "cm" into a numeric value.
I have looked at and tried the "Parse Number" operator. However this fails. The meta-data
still shows a nominal type and the process complains about a non-numerical value
used in the "cosine similarity measure". I also fail top see how I can inform this operator to
ignore the "cm" text.

Anyone know how I can do this? Any existing operator for this?

Hugo F.



  • Options
    Nils_WoehlerNils_Woehler Member Posts: 463 Maven

    you can use Replace for this:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.005">
      <operator activated="true" class="process" compatibility="5.3.005" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="5.3.005" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="179" y="165">
            <list key="attribute_values">
              <parameter key="measure" value="&quot;5 cm&quot;"/>
            <list key="set_additional_roles"/>
          <operator activated="true" class="replace" compatibility="5.3.005" expanded="true" height="76" name="Replace" width="90" x="380" y="165">
            <parameter key="replace_what" value=" cm"/>
          <operator activated="true" class="parse_numbers" compatibility="5.3.005" expanded="true" height="76" name="Parse Numbers" width="90" x="581" y="165"/>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Replace" to_port="example set input"/>
          <connect from_op="Replace" from_port="example set output" to_op="Parse Numbers" to_port="example set input"/>
          <connect from_op="Parse Numbers" from_port="example set output" 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"/>
  • Options
    UgoUgo Member Posts: 20 Contributor II
    Hello Nils,

    Worked perfectly (including meta-data prior to execution)

    Thank you,
    Hugo F.
Sign In or Register to comment.