Grooper 21.00.0082 is available as of 12-12-2023! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.00.0042 is available as of 03-22-2024! Check the Downloads Discussion for the release notes and to get the latest version.
Grooper 23.1.0018 is available as of 04-15-2024! Check the  Downloads Discussion  for the release notes and to get the latest version.
Options

Need to normalize Percent values

rcawthonrcawthon Posts: 4
edited March 2020 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

  • Options
    RandoCalrisianRandoCalrisian Posts: 195 admin
    edited March 2020
    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
    rkinard@bisok.com

  • Options
    RandoCalrisianRandoCalrisian Posts: 195 admin
    edited March 2020
    See images below for how the Data Formats were built, and attached is a .zip file from Grooper 2.80.





    Randall Kinard
    rkinard@bisok.com

  • Options
    RandoCalrisianRandoCalrisian Posts: 195 admin
    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
    rkinard@bisok.com

  • Options
    RandoCalrisianRandoCalrisian Posts: 195 admin
    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.
    (?! ?%<span>)</span>
    Randall Kinard
    rkinard@bisok.com

Sign In or Register to comment.