Ignore small decimal differences

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • th3ufo
    New User
    • Dec 2017
    • 2

    Ignore small decimal differences

    I compare two files that contain small difference in decimal part of numbers, due to rounding a number 109927.77777777 in one file is represented in another file as 109927.77777778 but i would like to ignore such small differences. I would appreciate if some of you could share an idea of how this can be acomplished.

    File2:
    Volume = 113111.11111112 127422.22222222 113497.22222222 106088.37888889 109927.77777777 106419.00444444 106419.44444444

    File1:
    Volume = 113111.11111112 127422.22222222 113497.22222222 106088.37888888 109927.77777778 106419.00444445 106419.44444445
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    Hello,

    If your data can be delimited and viewed in the Table Compare session type, each Numeric column can have an associated Numeric Tolerance to ignore a change like this.

    In the Text Compare session, the characters are just text (not a number), so ignoring it is a bit trickier. We'd have to create a grammar that matches on this spot of the line. I'd recommend defining a grammar for the Important part of the number:
    \d+\.\d{5}
    where "5" is the number of characters after the decimal that are important.

    Then in the Text Compare, Session Settings, Importance tab, you can check this new grammar's name, and uncheck Everything Else. This will make this part of the number important, and everything else on the line unimportant. If you need to define additional grammars (for "Volume =" or other text), these can also be Important.
    Aaron P Scooter Software

    Comment

    • th3ufo
      New User
      • Dec 2017
      • 2

      #3
      Thanks a lot for your help, Aaron!

      Comment

      • rilhutch18
        New User
        • Sep 2022
        • 2

        #4
        Hello! I have a similar issue that I'm really struggling with!

        My string looks like this:
        N1188 X5.463974 Y32.198956 Z20.520843
        N1190 Y29.190685 Z20.62076
        N1190 Y29.190685 Z20.62
        N1192 G1 X5.463969 Y29.190688 Z6.070015 F500.
        N1194 X4.963971 Y29.192269 Z6.070018 F600.​

        My current regex is this:
        (?<=\.\d{4})\d+

        When I attempt to confirm the Grammer Item, I get the following error:
        "Invalid regular expression:"
        "Character expected at position 2"

        I've checked this regex pattern + string on a variety of different Perl regex sites and all of them produce the intended results (find all digits following the 4th).

        Does anyone have any insight into what may be causing the error... better yet, what does the error mean?

        I'm on verison 4.2.4 (build 22795).

        Thanks in advanced!!

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 16000

          #5
          Hello,

          The RegEx supported in this dialog is a subset of the full regex capability. Specifically it is missing back references and look backs so it would have issues with ?<=. If you click the small dropdown arrow next to the text field, you can see the list of possible commands for that dialog. It's on our wishlist to expand our RegEx support throughout the program.

          All 4.x updates are free for 4.x users. So if your IT dept gives the green light, you can update to the latest (4.4.3 currently) whenever you'd like, though it won't directly address this limitation.
          Aaron P Scooter Software

          Comment

          • rilhutch18
            New User
            • Sep 2022
            • 2

            #6
            Thank you Aaron! I appreciate the timely response!

            Comment

            • anorec
              Visitor
              • Nov 2022
              • 4

              #7
              Hi,

              I am a fresh new user and was trying to color syntax my CNC files. I failed and i fell on that topic.

              Here is my example:
              i was trying to make a grammar regex to extract 'G2' (or 'G02 or 'G03' or 'G3') but not followed by other digits (G2X0 is OK but G28X0 is not)

              Regex 'G[0]?[2|3](?![0-9])' seems to work in any Perl online tester but i encounter same issue as author regarding look ahead (?!) feature.

              I'm not a regex expert so is there a workaround? Does lookahead implementation is planned to Beyond compare?

              Comment

              • Aaron
                Team Scooter
                • Oct 2007
                • 16000

                #8
                Hello,

                Your analysis is correct: BC4's RegEx is limited and doesn't support lookahead. If you click the small dropdown arrow next to the textbox, we populate the subset of RegEx supported for each specific field (such as, often the Replace With field is limited to Tagged Expressions).

                It's on our Customer Wishlist to expand our RegEx support, but it isn't currently scheduled development. Our wishlist is where our developers go for ideas for future features and enhancements, and I'll add your notes and example to our notes on the subject. Do you have a full line of text, or two, you could include as an example and let us know specifically what you are trying to ignore? We may be able to help with a current regex and I can also add the example as additional notes.
                Aaron P Scooter Software

                Comment

                • anorec
                  Visitor
                  • Nov 2022
                  • 4

                  #9
                  Hi Aaron,
                  Thank you for your quick response and support!

                  I'm using CNC fanuc style files (https://en.wikipedia.org/wiki/G-code.)
                  Lines are composed of blocks (one 'address' with an alphabetic character (A-Z) followed by a value number (integer or decimal)

                  Here are 2 lines example:
                  N390 G3 X-42.111 Y99.96 Z39.3 I10.867 J2.913
                  N12220 G30 G91 X0. Y0.

                  What i would like to achieve is making grammar rules to identify some blocks, specifically with G adresses here.
                  It could permit to color them independantly. G3 block on first line should be a different color than G30 block on second line.

                  Here is a coloring code example from my text editor (CimcoEdit from https://www.cimco.com/)
                  Cliquez sur l'image pour la voir en taille réelle   Nom : 		image.png  Affichages :	15  Taille :		5,8 Ko  ID : 			89226

                  What would be awesome too would be to leverage these grammar rules to filter some minor differences based on values but i don't know if that could be possible.
                  What i mean is that on my first line example G3 block is equals to G03 (or G00003) and could be filtered in a text comparison.
                  Attached Files
                  Last edited by anorec; 30-Nov-2022, 03:16 AM.

                  Comment

                  • Chris
                    Team Scooter
                    • Oct 2007
                    • 5538

                    #10
                    To create grammar rules to identify G3 and G30 separately:

                    Open Tools > File Formats.
                    Click + and select Text Format.
                    In the General tab, enter a file mask for your files, like *.g. Multiple masks are separated with semicolons.
                    Go to the Grammar tab.
                    Click + in the top of the dialog.
                    Element name: G3
                    Category: Basic
                    Text matching: G0*3
                    Check Regular expression.
                    Click OK.
                    Click + in the top of the dialog.
                    Element name: G30
                    Category: Basic
                    Text matching: G0*30
                    Check Regular expression.
                    Click OK until back to the main window.

                    To set colors for the grammar elements:
                    Select Tools > Options from the menu.
                    Go to the Colors, Fonts section.
                    Go to the File Views tab.
                    In the Elements list, under Syntax highlighting, select G3, then assign it a text color. Repeat for G30.

                    Note that syntax highlighting is only used for matching text. Difference coloring takes precedence over syntax highlighting.

                    To mark text unimportant for the current comparison as a one-off in the Text Compare, click the Rules toolbar button (referee icon).
                    Go to the Importance tab.
                    In the Unimportant text section, click +, then enter text to match on.

                    To always mark text unimportant, define a grammar element for it, then click the Rules toolbar button. In the Importance tab, uncheck the grammar element to make it unimportant.

                    See also: https://www.scootersoftware.com/supp..._unimportantv3







                    Chris K Scooter Software

                    Comment

                    • anorec
                      Visitor
                      • Nov 2022
                      • 4

                      #11
                      Thank you that works.

                      Comment

                      Working...