paulfitz / daff

align and compare tables
https://paulfitz.github.io/daff
MIT License
801 stars 67 forks source link

diffs inside cells -- that is, give daff cell format awareness #196

Open justin2004 opened 1 year ago

justin2004 commented 1 year ago

great tool, btw!

it would be really slick if when a cell differs, daff could look inside the cells and do a diff on the content.

e.g.

daff_example1.csv:

name,age,more_stuff
fred,23,"{""dogs"": """", ""residence"": ""Poland"", ""language"": ""English"", ""trick_or_treats"": ""true""}"
bob,45,"{""dogs"": ""fido"", ""residence"": ""USA"", ""language"": ""English"", ""trick_or_treats"": ""false""}"

daff_example2.csv:

name,age,more_stuff
fred,23,"{""dogs"": """", ""residence"": ""Poland"", ""language"": [""English"",""Polish""], ""trick_or_treats"": ""true""}"
bob,45,"{""dogs"": ""fido"", ""residence"": ""USA"", ""language"": ""English"", ""trick_or_treats"": ""false""}"
$ daff daff_example1.csv daff_example2.csv 
@@,name,age,more_stuff
→,fred,23,"{""dogs"": """", ""residence"": ""Poland"", ""language"": ""English"", ""trick_or_treats"": ""true""}→{""dogs"": """", ""residence"": ""Poland"", ""language"": [""English"",""Polish""], ""trick_or_treats"": ""true""}"
,bob,45,"{""dogs"": ""fido"", ""residence"": ""USA"", ""language"": ""English"", ""trick_or_treats"": ""false""}"

notice how daff shows that the whole cell in the more_stuff column has changed.

it would be nice if instead daff could produce output something like this:

$ daff daff_example1.csv daff_example2.csv 
@@,name,age,more_stuff
→,fred,23,"{ ... ""language"": ""English"" ... }→{ ... ""language"": [""English"",""Polish""] ... }"
,bob,45,"{""dogs"": ""fido"", ""residence"": ""USA"", ""language"": ""English"", ""trick_or_treats"": ""false""}"

indicating the key/value pair inside the cell that has changed.