Announcement

Collapse
No announcement yet.

How to correctly align number prefixed text files?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to correctly align number prefixed text files?

    Can anyone enlighten me how to align the following two files by their leading 6 digit numbers?
    I expect only those lines to be aligned where the leading 6 digit match exactly. The lines should also
    be aligned in case there is a trailing comment following the digits.

    I feel like I tried everything to get a reasonable alignment for the following two text file examples but with no satisfying results
    (grammar with leading 6 digits, first 6 columns; line weight for leading 6 digits set to high; etc. ...).

    Thanks!

    Code:
    FILE_1.TXT
    000001 comment
    000002
    000003 
    000004 comment
    000005
    000006 comment
    
    FILE_2.TXT
    000002
    000004
    000006
    000008
    
    EXPECTED ALIGNMENT
    000001 comment
    000002                000002
    000003 
    000004 comment        000004
    000005
    000006 comment        000006

  • #2
    Hello,

    For the Text Compare, the default alignment takes the whole line into account. Altering the Session Settings, Alignment tab may help get these to align in more general cases.

    Otherwise, you can define a grammar to match on your Line Number, then in the Session Settings -> Importance tab, make Line Number Important and everything else (all other grammars, "Everything Else", etc) unimportant by unchecking all other items. Then in the Alignment tab, set to Never Align Differences. Because all other items are unimportant, they will still align, but the Line Number grammar matching on this text is then pushed into alignment.

    To define a Line Number grammar, follow this guide:
    http://www.scootersoftware.com/suppo..._unimportantv3
    Except for the last step, where you leave the new grammar as checked (important) instead of unchecked (unimportant).
    One which might work for you is the RegEx:
    ^\d{6}
    Aaron P Scooter Software

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X