Announcement

Collapse
No announcement yet.

How to perform positional sort in a text file before text compare?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • How to perform positional sort in a text file before text compare?

    I wanted to compare 2 log files (length=200) with the below 2 conditions:
    (1) sort the files from col 1 - 149, followed by 161 -200, and
    (2) ignore timestamp different (col 150 - 160)

    I have used the Sorted text format and set unimportant text for col 150-160, this way, BC3 sorted the whole file first (including the timestamp) then perform text compare and ignore different in timestamp. I have a lot of different due to the 2 files are not in the same sorting order.

    Any advice would be appreciated.

    Thank you.

  • #2
    Hello,

    I think the easiest method may be to use our Data Compare session type, with a new File Format (Tools menu). Create a new Data format, and in the Type tab switch from delimited to Fixed. You can then define the column widths, such as 149;10;50.

    You can then mark any specific column as either a Key column, Standard, or Unimportant.
    The Key can be a single column or multiple columns; it is used to sort and align your data, and should be a unique identifier for the entire row. A couple examples would be an EmployeeID column, or the combination of FirstName column and LastName column. Keys must match exactly for two rows to align.

    The timestamp column can then also be marked as Unimportant, and the Ignore Unimportant Differences toggle enabled in the toolbar to hide any blue differences as black/equal.

    How does this work for you?
    Aaron P Scooter Software

    Comment


    • #3
      In addition, you can define your own custom "sort" as a command line External Conversion. Here is an example of how to re-format text for the Text Compare:

      http://www.scootersoftware.com/suppo...rnalconversion
      Aaron P Scooter Software

      Comment


      • #4
        This work perfectly. Thank you for the suggestion. I am now able to compare text file the same way as data file.

        However, this works fine if I have a few text files to works with. But our project has more than a thousand files to be compared at intervals of our system test, so was thinking of using the script to run the compare, but here's the problem, all the text file have different file length and the key column for sorting are different and unimportant column are different as well. Is there a way to define various setting/rules for each file using script ?

        Comment


        • #5
          I was refering to your first method using the Data Compare session.

          Comment


          • #6
            Sorry, another question relating to "wrap-around" text file.

            I have one system platform generating an output file with 100 records, for example, and each record is a row, so I have 100 rows in this file. But the other platform produced a similar file but all records were wrap-around, e.g. every record was linked together one after another to become 1 row (no line break), so there is only one row in this file.

            How do I reformat the wrap-around file (using Beyond Compare script) so that it become 100 rows and allow me to do proper compare with the other file?

            Comment


            • #7
              Hello,

              For the Data Compare file format, all the files of the same extension (*.dat) would need to have the same fixed length records. If they do not, you would need to define a delimiter.

              Or use a custom conversion to give them a delimiter, and then open them in the Data Compare or Text Compare.
              Aaron P Scooter Software

              Comment


              • #8
                Hello,

                For the wrap around, if you define a fixed length File Format, it should "wrap" whenever it hits the end of the current fixed length definition. Example: 5;5;5, would wrap after the 15th character.

                Otherwise, you will need to use a custom external conversion to insert line breaks, or manually fix the file.

                The Text Compare format offers an overall value for when it should wrap, called the Characters per line limit. The default is 4096 characters.
                Aaron P Scooter Software

                Comment


                • #9
                  Can this "charactor per line limit" in Text Compare be set in script ? so that I could compare set of different length files in one script...

                  Comment


                  • #10
                    Originally posted by Aaron
                    Hello,
                    (...)
                    Otherwise, you will need to use a custom external conversion to insert line breaks, or manually fix the file.
                    Perhaps the HTML/XML tidied formats would be the model for the external conversion. I would be inclined to use a scripting language such as awk, perl, or python to do this. Bigfoot doesn't say what platform the comparisons are being run on, but even on Windows there are easy ways to run most of the choices.

                    /dps

                    Comment


                    • #11
                      It cannot be set as a script. The option is designed as a fairly permanent option, set for a specific file extension.

                      Perhaps a more specific example of your files may help. Is every file pair you are dealing with a Fixed Length example, but their lengths are constantly changing? Are they input into other programs, and if so, how do these other programs know to interpret the data? Could the whitespace between entries be used as a delimiter, or is there also whitespace in the data?
                      Aaron P Scooter Software

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎