Need to normalize Percent values

rcawthonrcawthon Posts: 3
edited March 9 in The Astronauts (Q&A)
I am looking to normalize percent data were some of the data contains percent signs and some are just normal decimal representations.  I suspect this has a lot to do with my value extractors.  The data needs to be normalized to a decimal, ie 100 = 1.000  Thanks in advance for your help!


Examples:
100%
80.893%
100 %
80.893 %
.0993
1.00000

Answers

  • RandoCalrisianRandoCalrisian Posts: 171 ✭✭✭
    edited March 9
    It is my understanding that there is not a .Net Value Type that handles this easily. I could be wrong though ...
    I built something just now to tackle this by controlling formatting via Data Types with child Data Formats controlling the output via capture groups and specific Output Formats.


    Randall Kinard
    [email protected]

  • RandoCalrisianRandoCalrisian Posts: 171 ✭✭✭
    edited March 12
    See images below for how the Data Formats were built, and attached is a .zip file from Grooper 2.80.





    Randall Kinard
    [email protected]

  • RandoCalrisianRandoCalrisian Posts: 171 ✭✭✭
    Oh, and, the final bit to normalizing the data, is setting the Value Type, Format Specifier, and Min/Max values for the Data Field.

    Randall Kinard
    [email protected]

  • RandoCalrisianRandoCalrisian Posts: 171 ✭✭✭
    Update on this, as I noticed a couple of errors in what I built. The main thing is that I added a few more patterns, and leveraged, in a couple of the formats, what's called a negative look behind. The attachment from the previous comment was updated to reflect this.

    I'd like to reference the following website:
    https://www.regular-expressions.info/lookaround.html

    Grooper has built into it the usage of postive look aheads and look behinds, but you have to manually insert the syntax for negative look behinds. In the case of what I build, I needed there to be a difference between the following:

    0.12345 %
    .12345 %
    vs
    0.12345
    .12345

    The percent sign at the end is obviously very important because 0.12345% = 0.0012345 while 0.12345 = 0.12345. The best way I could think to differentiate the two patterns was with the use of the negative look behind on the percentage amounts not using the % sign.
    (?! ?%)
    Randall Kinard
    [email protected]

Sign In or Register to comment.