Finding particular column value via regex
<p>I have a txt file containing multiple rows as below. </p>

<pre><code>56.0000         3       1
62.0000         3       1
74.0000         3       1
78.0000         3       1
82.0000         3       1
86.0000         3       1
90.0000         3       1
94.0000         3       1
98.0000         3       1
102.0000        3       1
106.0000        3       1
110.0000        3       0
116.0000        3       1
120.0000        3       1
</code></pre>

<p>Now I am looking for the row which has '0' in the third column . </p>

<p>I am using python regex package. What I have tried is <code>re.match("(.*)\s+(0-9)\s+(1)",line)</code> but of no help.. </p>

<p>What should be the regular expression pattern I should be looking for?</p>

<p>Just split line and read value from list.</p>

<pre><code>&gt;&gt;&gt; line = "56.0000         3       1"
&gt;&gt;&gt; a=line.split()
&gt;&gt;&gt; a
['56.0000', '3', '1']
&gt;&gt;&gt; print a[2]
1
&gt;&gt;&gt;
</code></pre>

<p><strong>Summary:</strong></p>

<pre><code>f = open("sample.txt",'r')
for line in f:
    tmp_list = line.split()
    if int(tmp_list[2]) == 0:
        print "Line has 0"
        print line
f.close()
</code></pre>

<p>Output:</p>

<pre><code>C:\Users\dinesh_pundkar\Desktop&gt;python c.py
Line has 0
110.0000        3       0
</code></pre>

python regex