CSV File questions: Align With? Sort by row number? Open once as a different type?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimMcDaniel
    New User
    • Aug 2015
    • 2

    CSV File questions: Align With? Sort by row number? Open once as a different type?

    As a new user, I didn't want to spam the forum. I hope it's OK to bundle several questions.

    I have a script that outputs CSV files, and I'm trying to compare output from a previous version to the latest version. I'm using BC 4.0.7 on Windows.

    (1) I made a change that added a few rows. In BC4, in CSV files it doesn't match one line with a later one like in a normal text file. In a normal text file in BC, I'd use F7 / Align With ..., but that isn't available. Is there some way to do it? (Other than deleting the putative added rows, saving, and redoing the comparison.) Can I request it?

    (2) It seems to be sorting by the primary key, by default the first column. Is it possible to sort by row number? (Other than by changing the output by putting the row number in coumn 1.)

    (3) I mentioned above how it doesn't seem to have the same operations with CSV files as text files. Is there a way to, just one time, do the comparison as text files? (I hesitate to muck around with Tools - File Formats for fear that I'll somehow lose the CSV file functionality.)
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    Hello,

    No problem. I'll go through and try to help with each of these:

    1) The Table Compare does not include an Align With command. Instead, the alignment is controlled by the Key column(s). By default this is column 1, but you can right click any column header to set as a Standard, Unimportant, or Key. If you set multiple columns as Key, then together they form the Key. A Key should be a unique identifier for the data, such as an EmployeeID column, or FirstName and LastName columns together.

    Does your CSV output have a Key column that can be used, and is the Table Compare currently configured to use it?

    2) You can disable the sorting on Key in the Session menu -> Session Settings, Columns tab, enable "Unsorted Alignment" at the bottom. The Key is still used to determine if two rows should align, but isn't sorted. If there is no Key, then the entire row must match, so the best solution here would be to make one of your columns the Row Number and use that as the Key if you want to align by that information.

    3) Yes, use the Session menu -> Compare Files Using -> Text Compare. You can have multiple formats defined in the File Formats dialog; the topmost format is what is used automatically and determines which session type is used. You can also have a Text format for CSV files, as long as it is lower in the priority list it won't be used unless you use this command, or launch a blank Text Compare first and then open your files.
    Aaron P Scooter Software

    Comment

    • TimMcDaniel
      New User
      • Aug 2015
      • 2

      #3
      Thanks for the reply!

      Unfortunately, there are about 10 keys, so it'll be tedious to define them all every time. I guess I'll play with defining many keys or removing all keys.

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16000

        #4
        Hello,

        10 different Key combinations for different files? Or 10 columns that together form the Key? You can save a Session to load later if you need to recompare the files.
        Aaron P Scooter Software

        Comment

        • maurice
          Enthusiast
          • Jan 2008
          • 42

          #5
          I recently was asked to help someone with a CSV/Table compare, and also ran into the need to set about 10 columns as keys. I was surprised to see that we could not select multiple columns to set the column type either from the file/table compare view or the session settings view of all the columns. I suggest adding this in a future update.

          For anyone else reading this, one very confusing aspect comparing two files directly (right-click one, then the other file) is that the only real option available to save your "session settings" (selected key columns, etc) is to update the session defaults (your original "Data Compare" session). Via the drop-list at the bottom of the Sessions Settings window (easy to miss).

          If you create a FOLDER compare session that contains your .CSV files, THEN compare two files, you will have two additional options, but the one most people will want is "Use for all files within parent session". Your column type settings will be stored in the FOLDER Compare session...even though you can't see them from the session settings tabs! You have to actually compare two files to see those settings! (Once you have a FOLDER session saved, you can open that session, navigate to different folder/s and still have your saved CSV key settings.) Still confused? You're not alone.

          The Help file on "Session Settings" is very clear on this, but it's still confusing to me in practice:
          Additional choices are shown for child sessions, comparisons spawned from a folder session. Use for these files within parent session causes the current folder session to remember these settings and use them whenever this particular pair of files is compared. Use for all files within parent session causes these settings to be used for any new sessions of this type spawned from the current folder session.

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 16000

            #6
            Hello,

            The Session Settings dialogs are context sensitive, and only show the options for the current view. As you've found, you want to have a saved Folder Compare, then open a pair of files in a child view if you need to update child settings. The child view settings can apply to the current view, also update the parent view to use these settings for this specific pair of files, also update the parent view to use these settings for any files of the same viewer type (Text, Table, MP3, etc), or update the global defaults for any future view of that type: inside or outside of the parent session.

            Reorganizing this interface is something we would like to tackle, but is tricky to expose the many possible child settings.
            Aaron P Scooter Software

            Comment

            • tricky
              New User
              • Mar 2019
              • 2

              #7
              I had a similar problem and used the unimportant, then unaligned, now the second file starts at line 2 meaning everything is miss-aligned.
              How do I get the first line to show in the second file/window?

              Comment

              • Aaron
                Team Scooter
                • Oct 2007
                • 16000

                #8
                Hello,

                Unaligned will align Row to Row without any alignment, and won't handle any insertions.

                Which version of Beyond Compare are you using? BC 4.2.9 includes different alignment solutions in the Table Compare's Session menu -> Session Settings, Alignment, and Standard alignment may help. Or if you have a Key column you can define (to sort and align by) the Sorted alignment would work.
                Aaron P Scooter Software

                Comment

                • tricky
                  New User
                  • Mar 2019
                  • 2

                  #9
                  Sorry, the first window had opened with Table Format|Type|First line contains: Detect, while the second had selected Column names.
                  One is showing the commas, while the other isn't, but that is fine for the checking that I am doing. (Yes, 4.2.9). Thanks.

                  Comment

                  • Aaron
                    Team Scooter
                    • Oct 2007
                    • 16000

                    #10
                    And updating the File Format helped format your data better? If you are still having any trouble, let us know.
                    Aaron P Scooter Software

                    Comment

                    Working...