Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C csvkit
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wireservice
  • csvkit
  • Merge requests
  • !103

implementation of csvdiff (issue #12)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/ewheeler/csvdiff into master Aug 30, 2011
  • Overview 0
  • Commits 6
  • Pipelines 0
  • Changes 1

Created by: ewheeler

    Diff two csv files
    Each row of diff begins with a two-letter code:
            Code    Meaning
            '- '    row unique to file 1
            '+ '    row unique to file 2
            '  '    row common to both files
            '? '    row different in both files, only different cell values are shown
    Followed by the filename of the row and the cell values.
    Note: when called with --ignorediff, a single row is given for each pair of
          matching rows, without line numbers or file information

$ csvdiff examples/testfixed_converted.csv examples/testxls_converted.csv 
  ,0,examples/testfixed_converted.csv,text,date,integer,boolean,float,time,datetime,empty_column
  ,0,examples/testxls_converted.csv,text,date,integer,boolean,float,time,datetime,empty_column
  ,1,examples/testfixed_converted.csv,Chicago Reader,1971-01-01,40,True,1.0,04:14:00,1971-01-01T04:14:00,
  ,1,examples/testxls_converted.csv,Chicago Reader,1971-01-01,40,True,1.0,04:14:00,1971-01-01T04:14:00,
? ,2,examples/testfixed_converted.csv,Chicago Sun-Times,1948-01-01,63,True,1.24,14:57:13,1948-01-01T14:57:13,
? ,2,examples/testxls_converted.csv,Chicago Sun-Times,1948-01-01,63,True,1.27,14:57:13,1948-01-01T14:57:13,
  ,3,examples/testfixed_converted.csv,Chicago Tribune,1920-01-01,164,False,41800000.01,00:00:00,1920-01-01T00:00:00,
  ,3,examples/testxls_converted.csv,Chicago Tribune,1920-01-01,164,False,41800000.01,00:00:00,1920-01-01T00:00:00,
? ,4,examples/testfixed_converted.csv,Row with blanks,,,,,,,
? ,4,examples/testxls_converted.csv,This row has blanks,,,,,,,
? ,5,examples/testfixed_converted.csv,,,,,,,,
? ,5,examples/testxls_converted.csv,Unicode! Σ,,,,,,,

the --noequal option excludes identical rows that are common to both files:

$ csvdiff -n examples/testfixed_converted.csv examples/testxls_converted.csv 
? ,2,examples/testfixed_converted.csv,Chicago Sun-Times,1948-01-01,63,True,1.24,14:57:13,1948-01-01T14:57:13,
? ,2,examples/testxls_converted.csv,Chicago Sun-Times,1948-01-01,63,True,1.27,14:57:13,1948-01-01T14:57:13,
? ,4,examples/testfixed_converted.csv,Row with blanks,,,,,,,
? ,4,examples/testxls_converted.csv,This row has blanks,,,,,,,
? ,5,examples/testfixed_converted.csv,,,,,,,,
? ,5,examples/testxls_converted.csv,Unicode! Σ,,,,,,,

the --onlydiffcells option limits row output to cells that are not common to both rows:

$ csvdiff -n -o examples/testfixed_converted.csv examples/testxls_converted.csv
? ,2,examples/testfixed_converted.csv,,,,,1.24,,,
? ,2,examples/testxls_converted.csv,,,,,1.27,,,
? ,4,examples/testfixed_converted.csv,Row with blanks,,,,,,,
? ,4,examples/testxls_converted.csv,This row has blanks,,,,,,,
? ,5,examples/testfixed_converted.csv,,,,,,,,
? ,5,examples/testxls_converted.csv,Unicode! Σ,,,,,,,

the --ignorediff option shows only identical rows that are common to both files:

$ csvdiff -i examples/testfixed_converted.csv examples/testxls_converted.csv
text,date,integer,boolean,float,time,datetime,empty_column
Chicago Reader,1971-01-01,40,True,1.0,04:14:00,1971-01-01T04:14:00,
Chicago Tribune,1920-01-01,164,False,41800000.01,00:00:00,1920-01-01T00:00:00,

the --columns option uses only a given column to compare rows:

$ csvdiff -c text -n examples/testfixed_converted.csv examples/testxls_converted.csv 
? ,4,examples/testfixed_converted.csv,Row with blanks,,,,,,,
? ,4,examples/testxls_converted.csv,This row has blanks,,,,,,,
? ,5,examples/testfixed_converted.csv,,,,,,,,
? ,5,examples/testxls_converted.csv,Unicode! Σ,,,,,,,

and the --colnames option will include the column names from both files:

$ csvdiff -c text -n -m examples/testfixed_converted.csv examples/testxls_converted.csv 
  ,,examples/testfixed_converted.csv,text,date,integer,boolean,float,time,datetime,empty_column
  ,,examples/testxls_converted.csv,text,date,integer,boolean,float,time,datetime,empty_column
? ,4,examples/testfixed_converted.csv,Row with blanks,,,,,,,
? ,4,examples/testxls_converted.csv,This row has blanks,,,,,,,
? ,5,examples/testfixed_converted.csv,,,,,,,,
? ,5,examples/testxls_converted.csv,Unicode! Σ,,,,,,,
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ewheeler/csvdiff