Re: [Tutor] 1 to N searches in files

2012-12-03 Thread Dave Angel
On 12/03/2012 10:46 AM, Spectral None wrote: > > Hi Dave > > Your solution seems to work: > > setA = set(FileA) > setB = set(FileB) > > for line in setB: > if line in setA: > matched_lines.writelines(line) > else: > non_matched_lines.writelines(line) > > There are no duplicates in

Re: [Tutor] 1 to N searches in files

2012-12-03 Thread Spectral None
tain implementation details about how integers are stored, namely that they are two-compliment rather than one-compliment or something more exotic. Okay, just about every computer made since 1960 uses two-compliment integers, but still, the effect of ~i depends on the way integers are represent

Re: [Tutor] 1 to N searches in files

2012-12-03 Thread Spectral None
From: Dave Angel To: Spectral None Cc: "tutor@python.org" Sent: Sunday, 2 December 2012, 20:05 Subject: Re: [Tutor] 1 to N searches in files On 12/02/2012 03:53 AM, Spectral None wrote: > Hi all > > I have two files (File A and File B) with strings of data in them (

Re: [Tutor] 1 to N searches in files

2012-12-02 Thread Dave Angel
On 12/02/2012 03:53 AM, Spectral None wrote: > Hi all > > I have two files (File A and File B) with strings of data in them (each > string on a separate line). Basically, each string in File B will be compared > with all the strings in File A and the resulting output is to show a list of > match

Re: [Tutor] 1 to N searches in files

2012-12-02 Thread Steven D'Aprano
On 02/12/12 19:53, Spectral None wrote: However, it seems that the results do not correctly reflect the matched/unmatched lines. As an example, if FileA contains "string1" and FileB contains multiple occurrences of "string1", it seems that the first occurrence matches correctly but subsequent "

[Tutor] 1 to N searches in files

2012-12-02 Thread Spectral None
Hi all I have two files (File A and File B) with strings of data in them (each string on a separate line). Basically, each string in File B will be compared with all the strings in File A and the resulting output is to show a list of matched/unmatched lines and optionally to write to a third Fi