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! Σ,,,,,,,