Matching files using python program
<p>I have to two files as follows</p>

<pre><code>File1
ids
CID5265
CID7263
CID9289
....

File 2
ids
CID7363  3.5e-06 -3837 
CID5265  4.5      -938
CID9289  8.9      -9873
....
</code></pre>

<p>I want  compare file1 with file2  to match any ids in file1 is present in file2 if yes  i should print whole line as follows</p>

<pre><code>CIDS9289  8.9  -9873
....
</code></pre>

<p>to acheive this wrote python script as follows</p>

<pre><code>infile = open("file1","r")

searchtxt = open("file2.txt","r")

for line in infile.readlines():

    if searchtxt in line:

       print line
</code></pre>

<p>but i gives following error</p>

<pre><code>Traceback (most recent call last):
  File "finding_words.py", line 7, in &lt;module&gt;
    if searchtxt in line:
TypeError: 'in &lt;string&gt;' requires string as left operand, not file
</code></pre>

<p>I know im doing very simple mistake but not able to figure it out can anybody tell how to solve this..</p>

<p>THanks in advance</p>

<p>NI</p>
