Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Can I convert string to number (Select value step)

  1. #1
    Join Date
    Sep 2011
    Posts
    171

    Default Can I convert string to number (Select value step)

    Hello everyone!

    I wonder if it is possible to convert string to number (maybe with JavaScript)

    I tried Select value step, but conversion did not work.

    Thank you,
    Alex

  2. #2
    Join Date
    Feb 2009
    Posts
    321

    Default

    alex, try using the last tab in select values step (metadata), that is more efficient, also you could use javascript with the function str2num ,

  3. #3
    Join Date
    Sep 2011
    Posts
    171

    Default

    Thank you! I used JavaScript with parseFloat()

    metadata of select value step did not work in my case.

  4. #4
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    WHAT didn't work? HOW did you try to convert WHICH string? It kind of matters.

  5. #5
    Join Date
    Dec 2009
    Posts
    609

    Default

    Easy Matt
    you should implement the method wildAssGuessWhatPeopleReallyReferTo()

    ...Perhaps one day people will be able to post good thread-starters

    @august: provide some more information please so we can help you:
    What kind of value/string did you want to convert?

    Cheers,

    Tom

  6. #6
    Join Date
    Sep 2011
    Posts
    171

    Default

    Here is an example.

    I was not sure if Select value was design for it, so I did not attache the example upfront.

    Here is an error message:

    Sorry, if I miss something.

    2011/10/20 15:18:46 - Spoon - Logging goes to file:///C:/Users/sviridap/AppData/Local/Temp/spoon_b6bdf174-fb58-11e0-a1c1-571184712127.log
    2011/10/20 15:18:48 - Version checker - OK
    2011/10/20 15:18:49 - class org.pentaho.agilebi.platform.JettyServer - WebServer.Log.CreateListener localhost:10000
    2011/10/20 15:18:51 - Spoon - Asking for repository
    2011/10/20 15:19:34 - Spoon - Save as...
    2011/10/20 15:19:34 - Spoon - Save file as...
    2011/10/20 15:30:57 - Spoon - Transformation opened.
    2011/10/20 15:30:57 - Spoon - Launching transformation [Test]...
    2011/10/20 15:30:58 - Spoon - Started the transformation execution.
    2011/10/20 15:30:58 - Test - Dispatching started for transformation [Test]
    2011/10/20 15:30:58 - Transformation metadata - Natural sort of steps executed in 1 ms (5 time previous steps calculated)
    2011/10/20 15:30:58 - Microsoft Excel Input.0 - Finished processing (I=2, O=0, R=0, W=2, U=0, E=0)
    2011/10/20 15:30:58 - Select values.0 - Finished processing (I=0, O=0, R=2, W=2, U=0, E=0)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Unexpected error
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : org.pentaho.di.core.exception.KettleValueException:
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Unexpected conversion error while converting value [MarketValueNoNull String] to a Number
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) :
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : MarketValueNoNull String : couldn't convert String to number
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Unparseable number: " 200739.870544429"
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) :
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) :
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.core.row.ValueMeta.getNumber(ValueMeta.java:1441)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.trans.steps.selectvalues.SelectValues.metadataValues(SelectValues.java:332)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.trans.steps.selectvalues.SelectValues.processRow(SelectValues.java:383)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.trans.step.RunThread.run(RunThread.java:40)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at java.lang.Thread.run(Unknown Source)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Caused by: org.pentaho.di.core.exception.KettleValueException:
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : MarketValueNoNull String : couldn't convert String to number
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Unparseable number: " 200739.870544429"
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) :
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.core.row.ValueMeta.convertStringToNumber(ValueMeta.java:698)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.core.row.ValueMeta.getNumber(ValueMeta.java:1394)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : ... 4 more
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Caused by: java.text.ParseException: Unparseable number: " 200739.870544429"
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at java.text.NumberFormat.parse(Unknown Source)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : at org.pentaho.di.core.row.ValueMeta.convertStringToNumber(ValueMeta.java:694)
    2011/10/20 15:30:59 - Select values 2.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : ... 5 more
    2011/10/20 15:30:59 - Select values 2.0 - Finished processing (I=0, O=0, R=1, W=0, U=0, E=1)
    2011/10/20 15:30:59 - Test - Test
    2011/10/20 15:30:59 - Test - Test
    2011/10/20 15:30:59 - Formula.0 - Finished processing (I=0, O=0, R=2, W=2, U=0, E=0)
    2011/10/20 15:30:59 - Spoon - The transformation has finished!!
    2011/10/20 15:30:59 - Test - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Errors detected!
    2011/10/20 15:30:59 - Test - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Errors detected!
    Attached Files Attached Files

  7. #7
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    You need conversion mask " #.#" (. as decimal)
    Note the space before #.#

  8. #8
    Join Date
    Sep 2011
    Posts
    171

    Default

    Thank you!

    I guess an extra space was the issue. It seems like it works even without #.# format selection

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.