Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Javascript - Convert string to number (with a negative sign)

  1. #1

    Default Javascript - Convert string to number (with a negative sign)


    I'm not very familiar with Javascript and I'd like to convert a number within a string variable (I'm parsing an excel report where all the data is contained in cell A). Right now, I've been able to extract the data I want and I have as an example "-5000.00" in a string variable. I tried using the calculator to create a copy of field A and automatically cast it to a number but it fail when there's negative values (positive works though).

    So now I come back to my JavaScript step and my guess is that I certainly can cast this string into a number directly in there but can't figure out :-( Anyone can help on this matter please?

    Thank you for your time.


  2. #2
    Join Date
    Jun 2012


    Is it parseFloat() you are looking for?

    Out of curiosity: Why don't you just change the data type from String to Number in your Excel Input step?
    So long, and thanks for all the fish.

  3. #3


    I'll have a look at parseFloat, thanks!

    As for the Excel input step, I can't; everything is contained within the first cell so my Excel input has only 1 field with tons of text and numbers of all kind

  4. #4


    Ok, tried with parseFloat and it works great. Thanks Marabu!

Tags for this Thread

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.