how to compare 2 very large textfiles

Dick Kriesel dick.kriesel at mail.com
Thu Oct 6 15:13:54 CDT 2011


On Oct 5, 2011, at 3:00 PM, Matthias Rebbe wrote:

> Hi,
> 
> i need to compare two very large text files with about 5000 - 7000 lines each with a lines size of up to 256 chars.
> 
> I need to find out if there are lines missing in either file a or file b.
> 
> What is the best way to do this with good speed?

Hi, Matthias.  Here's another contender:

<script>
   repeat for each line tLine in tList1
      put empty into tArray1[ tLine ]
   end repeat
   repeat for each line tLine in tList2
      if tLine is not among the keys of tArray1 then
         put empty into tArray2[ tLine ]
      end if
      delete variable tArray1[ tLine ]
   end repeat
   put the keys of tArray1 into tList1ButNotList2
   put the keys of tArray2 into tList2ButNotList1
</script>

Please do share the results of your speed comparisons.

-- Dick


More information about the use-livecode mailing list