MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: comparing big notebooks with diff

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45469] Re: [mg45344] comparing big notebooks with diff
  • From: Dale Horton <daleh at wolfram.com>
  • Date: Fri, 9 Jan 2004 05:20:36 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

At 04:54 AM 1/1/2004, Christopher Purcell wrote:
>Too frequently I have to search for unintended changes I have made in
>large notebooks. If I am lucky I have a previous version to compare
>with. Here is an interface to the Unix (and Mac OSX) diff command,
>which I find useful, since it can compare huge files very fast. It
>would be great if some Notebook wizard would take this routine and add
>the possibility of opening both files being compared in nicely
>sized/positioned windows and color highlighting the differences. This
>also works on Windows if the Cygwin Unix emulator is installed. If not,
>the DOS command FC could probably be substituted for diff.
>
>diff::usage="diff[file1,file2] provides an interface to the diff
>routine on Unix-like operating systems. The following command:
>Transpose[Drop[Transpose[Flatten[Map[ReadList[StringToStream[#[[1]]],{Nu
>mber,Character,Number}]&,
>Partition[diff[file1,file2],4] ],1] ],{2}]]
>extracts just the pairs of line numbers of the files,that could be used
>as pointers if they were read with something like:
>data1=ReadList[file1,Record,NullRecords->True];
>data2=ReadList[file2,Record,NullRecords->True];
>Here is an example of usage:
>\"This statement is false\">>junk1.txt
>\"This statement is true\">>junk2.txt
>diff[\"junk1.txt\",\"junk2.txt\"] ";
>
>diff[file1_String,file2_String]:=
>Module[{log},(Run["diff"<>" "<> file1<>" "<> file2<>">"<>"diff.log"] ;
>log=ReadList["diff.log",Record];DeleteFile["diff.log"];log)];
>
>
>Christopher Purcell
>Sensors & Actuators Group
>DRDC-Atlantic, 9 Grove St., PO Box 1012,
>Dartmouth NS B2Y 3Z7 Canada
>Tel 902-426-3100 x389
>Fax 902-426-9654

In v5, there is such a function, NotebookDiff, in AuthorTools.
-Go to the menu File>Palettes>Open AuthorTools.
-Press NotebookDiff.
-Press Notebooks...
-In the dialog press Select (to select an open notebook) or Browse (to 
select a notebook file) for the 2 notebooks.
-Press compare

This creates a new notebook with a list of the differences. If you select 
the triangle to the left of a difference it will show you the cells that 
are different.

If you want to see the differences in context, press the link for that 
difference. It will show the 2 original notebooks side-by-side with the 
cells highlighted. The list of differences are now at the bottom of the 
screen. You can also use this side-by-side view to apply changes from one 
notebook to the other.

-Dale


  • Prev by Date: Definitive Mathematical Functions Site Now Online
  • Next by Date: Re: 2^20991011-1
  • Previous by thread: comparing big notebooks with diff
  • Next by thread: Re: Compile