Re: Compare 2 files and discard common lines

2008-06-03 Thread Lie
On May 29, 3:36 pm, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? It's so e

Re: Compare 2 files and discard common lines

2008-06-03 Thread Mark
On Thu, 29 May 2008 01:36:44 -0700, loial wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? Of course yo

Re: Compare 2 files and discard common lines

2008-06-02 Thread Paul McGuire
On May 29, 3:36 am, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? Take the

Re: Compare 2 files and discard common lines

2008-06-02 Thread Gabriel Genellina
2008/5/29, loial <[EMAIL PROTECTED]>: I have a requirement to compare 2 text files and write to a 3rd file only those lines that appear in the 2nd file but not in the 1st file. En Thu, 29 May 2008 18:08:28 -0300, BJörn Lindqvist <[EMAIL PROTECTED]> escribió: Open('3rd','w').writelines(set(

Re: Compare 2 files and discard common lines

2008-05-29 Thread BJörn Lindqvist
Open('3rd', 'w').writelines(set(open('2nd').readlines())-set(open('1st'))) 2008/5/29, loial <[EMAIL PROTECTED]>: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am w

Re: Compare 2 files and discard common lines

2008-05-29 Thread dwblas
On May 29, 1:36 am, loial <[EMAIL PROTECTED]> wrote: > only those lines that appear in the 2nd file but not in the 1st file. set(file_2_recs).difference(set(file_1_recs)) will give the recs in file_2 that are not in file_1 if you can store both files in memory. Sets are indexed and so are faster t

Re: Compare 2 files and discard common lines

2008-05-29 Thread alex23
On May 29, 6:36 pm, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? >>> file1

Re: Compare 2 files and discard common lines

2008-05-29 Thread afrobeard
Another way of doing this might be to use the module difflib to calculate the differences. It has a sequence matcher under it which has the function get_matching_blocks difflib is included with python. On May 29, 2:02 pm, Chris <[EMAIL PROTECTED]> wrote: > On May 29, 10:36 am, loial <[EMAIL PROT

Re: Compare 2 files and discard common lines

2008-05-29 Thread Chris
On May 29, 10:36 am, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? How larg

Re: Compare 2 files and discard common lines

2008-05-29 Thread Stefan Behnel
loial wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. lines_in_file2 = set(open("file2").readlines()) for line in open("file1"): if line not in lines_in_file2: print line

Re: Compare 2 files and discard common lines

2008-05-29 Thread Stefan Behnel
Kalibr wrote: > On May 29, 6:36 pm, loial <[EMAIL PROTECTED]> wrote: >> I have a requirement to compare 2 text files and write to a 3rd file >> only those lines that appear in the 2nd file but not in the 1st file. >> >> Rather than re-invent the wheel I am wondering if anyone has written >> anythin

Re: Compare 2 files and discard common lines

2008-05-29 Thread Kalibr
On May 29, 6:36 pm, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? You can u

Compare 2 files and discard common lines

2008-05-29 Thread loial
I have a requirement to compare 2 text files and write to a 3rd file only those lines that appear in the 2nd file but not in the 1st file. Rather than re-invent the wheel I am wondering if anyone has written anything already? -- http://mail.python.org/mailman/listinfo/python-list