11 votes

What text comparison software do you use?

I've only had exposure to Beyond Compare and would like your opinion/suggestions on what's good.

mostly, I use it to compare two different versions of similar csv and potentially to merge them. Next use case is to compare two versions of simple scripts to see what's been updated.

Command line tools are a little too much for me, but if it seem to be very important to learn I supposed I could be encouraged to do so.

10 comments

  1. [2]
    datavoid
    Link
    I use VSCode for pretty much everything text related. Open both files, open the Explorer in the sidebar, select both files in the 'Open Editors' sections, right click a file -> 'Compare Selected'

    I use VSCode for pretty much everything text related.

    Open both files, open the Explorer in the sidebar, select both files in the 'Open Editors' sections, right click a file -> 'Compare Selected'

    11 votes
    1. introspect
      Link Parent
      More specifically, when you are comparing two files, say file A and file B, you want to select the file that you think you want to see the changes on and click "Select For Compare", and the one...

      More specifically, when you are comparing two files, say file A and file B, you want to select the file that you think you want to see the changes on and click "Select For Compare", and the one that you want to diff with "Compare With Selected". It was confusing at first but the "selected" document should be the primary document if you get what I'm saying.

      3 votes
  2. [2]
    gadling
    Link
    I've used so many of these and I'll say there is still nothing as good as Beyond Compare. That said, as datavoid said, VS Code is pretty decent.

    I've used so many of these and I'll say there is still nothing as good as Beyond Compare. That said, as datavoid said, VS Code is pretty decent.

    7 votes
    1. photons
      Link Parent
      Agreed. I use Beyond Compare at work and I liked it so much that ended up getting a personal license for it. If I remember right it was a pretty cheap perpetual license.

      Agreed. I use Beyond Compare at work and I liked it so much that ended up getting a personal license for it. If I remember right it was a pretty cheap perpetual license.

      4 votes
  3. [2]
    MaoZedongers
    Link
    I just use diff If it's a lot, I just pipe the results to a file first. If I don't have diff available I just use an online diff checker. I've used Meld before, it's graphical.

    I just use diff

    If it's a lot, I just pipe the results to a file first.

    If I don't have diff available I just use an online diff checker.

    I've used Meld before, it's graphical.

    5 votes
    1. Nihilego
      Link Parent
      I don’t compare text often enough, but yeah, I do simply use diff, I’ve never used a text comparing tool before diff(or after), since my use cases are pretty simple.

      I don’t compare text often enough, but yeah, I do simply use diff, I’ve never used a text comparing tool before diff(or after), since my use cases are pretty simple.

      2 votes
  4. Jakobeha
    (edited )
    Link
    On macOS I use FileMerge. It comes with Xcode and as such is located in a weird place ("Applications > Xcode.app > Contents > Applications > FileMerge.app"), but you can access it via Spotlight. A...

    On macOS I use FileMerge. It comes with Xcode and as such is located in a weird place ("Applications > Xcode.app > Contents > Applications > FileMerge.app"), but you can access it via Spotlight. A simple tool but it does the job.

    When using IntelliJ I use its built in diff tools. Especially when doing VCS diffs or merge resolution, their VCS UI is really good. Similarly for VSCode or any other IDE.

    Vim and Emacs unfortunately don't seem to have good built-in diff tools, although Neovim has diffview.nvim. On the command line I use diff often, but I'll admit it's not nearly as good as the GUI tools, so it only works well for simple diffs.

    Lastly, when I need to generate a report for a diff, e.g. to share with others, I use diff2html

    3 votes
  5. xk3
    (edited )
    Link
    If the lines of the CSV are not sorted you could try sorting on a column then use something like kdiff3 for diffing. xsv sort will sort lexicographically It sounds like your CSVs are not too...

    If the lines of the CSV are not sorted you could try sorting on a column then use something like kdiff3 for diffing.

    xsv sort will sort lexicographically

    It sounds like your CSVs are not too different but in the case that your CSVs are a real mess without much similarity you could try sorting with a tool I wrote which will sort the lines based on the term similarity of all the columns:

    pip install xklb
    lb clustersort 1.csv 1_sorted.csv
    

    As for merging:

    If you just need to concatenate the CSVs use xsv cat

    Otherwise, if you can convert your CSVs to SQLITE with sqlite-utils...

    ie.

    pip install sqlite-utils
    sqlite-utils insert --alter --csv --detect-types 1.db tablename 1.csv
    

    then you can merge the SQLITE files together based on a specific column:

    lb mergedbs --pk id --upsert combined.db 1.db 2.db 3.db
    
    lb mergedbs -h
    usage: library merge-dbs DEST_DB SOURCE_DB ... [--only-target-columns] [--only-new-rows] [--upsert] [--pk PK ...] [--table TABLE ...]
    
        Merge-DBs will insert new rows from source dbs to target db, table by table. If primary key(s) are provided,
        and there is an existing row with the same PK, the default action is to delete the existing row and insert the new row
        replacing all existing fields.
    
        Upsert mode will update matching PK rows such that if a source row has a NULL field and
        the destination row has a value then the value will be preserved instead of changed to the source row's NULL value.
    
        Ignore mode (--only-new-rows) will insert only rows which don't already exist in the destination db
    
        Test first by using temp databases as the destination db.
        Try out different modes / flags until you are satisfied with the behavior of the program
    
            library merge-dbs --pk path (mktemp --suffix .db) tv.db movies.db
    
        Merge database data and tables
    
            library merge-dbs --upsert --pk path video.db tv.db movies.db
            library merge-dbs --only-target-columns --only-new-rows --table media,playlists --pk path --skip-column id audio-fts.db audio.db
    
            library merge-dbs --pk id --only-tables subreddits reddit/81_New_Music.db audio.db
            library merge-dbs --only-new-rows --pk subreddit,path --only-tables reddit_posts reddit/81_New_Music.db audio.db -v
    
    positional arguments:
      database
      source_dbs
    
    options:
      -h, --help            show this help message and exit
      --primary-keys PRIMARY_KEYS, --pk PRIMARY_KEYS
                            Comma separated primary keys
      --business-keys BUSINESS_KEYS, --bk BUSINESS_KEYS
                            Comma separated business keys
      --upsert
      --ignore, --only-new-rows
      --only-tables ONLY_TABLES, -t ONLY_TABLES
                            Comma separated specific table(s)
      --only-target-columns
      --skip-columns SKIP_COLUMNS
    
    2 votes
  6. TheMediumJon
    Link
    I've previously used 010 Editors's compare functionality, before I used Beyond. Most use cases Beyond will do just fine. If you want to see why two tars are differently sized but their opened...

    I've previously used 010 Editors's compare functionality, before I used Beyond.

    Most use cases Beyond will do just fine.

    If you want to see why two tars are differently sized but their opened content is equal, 010 might be more comfortable imo.

    2 votes
  7. balooga
    Link
    I've been a fan of kdiff3 for years and I'm not even a Linux user! There are binaries available for Windows and Mac. It's got a usable UI, smart whitespace display options, merge support...

    I've been a fan of kdiff3 for years and I'm not even a Linux user! There are binaries available for Windows and Mac.

    It's got a usable UI, smart whitespace display options, merge support (including auto-merge), 3-way diff/merge, recursive directory diffing, and it's FOSS. That ticks all my boxes. It's not the prettiest app but it's extremely capable. I configured git to use it for diffs and merges and it works like a champ. In a previous career I used the directory diff to compare a production site's web root with my local dev environment to detect PHP malware after the server was compromised. Nowadays I'm mostly using it to review staged files before committing them, or resolve merge conflicts.

    2 votes