Extract the data along with searched string in python
<p>My file (a table) actually looks like this.  I want to search for a string like "Vonmises" in the file.  Then that is the starting point of what I want to extract.  I have 9 tables like the ones shown below.  Now I can search for a "Vonmises" string in my file, but my question is how to extract the tabular data along with string. </p>

<p><strong>The code I wrote for searching 'Vonmises' string is:</strong></p>

<pre><code>import re
f_read = open('filename','r')
str='VON MISES'
for line in f_read:    
    m=re.search(str,line)
    if m:
        print line
</code></pre>

<p><strong>My actual table:</strong></p>

<pre><code>                          STRESSES IN QUADRILATERAL ELEMENT

    ELEMNT-ID GRID-ID FIB-DIS STRESSES IN ELEMNT COORD SYS PRINCIPAL STRESSES
                                Norm-X  Norm-Y  Shear-XY     Angle Major Minor Vonmises   
        1         2     45         234    4565    675         65     345   345   54345
                 43     32         444    3243    324         65     453   543   34223 

                           STRESSES IN QUADRILATERAL ELEMENT
   ELEMNT-ID GRID-ID FIB-DIS STRESSES IN ELEMNT COORD SYS PRINCIPAL STRESSES
                                 Norm-X Norm-Y Shear-XY     Angle Major Minor Vonmises   
        2        34    324        342    556     565         546    53   6543   3456
                 45    345        657    676     856         674    65   676    6766
</code></pre>

<p><strong>When I execute the above I code the result I get is:</strong></p>

<pre><code>  ELEMNT-ID GRID-ID FIB-DIS STRESSES IN ELEMNT COORD SYS PRINCIPAL STRESSES

  ELEMNT-ID GRID-ID FIB-DIS STRESSES IN ELEMNT COORD SYS PRINCIPAL STRESSES
</code></pre>

<p>So what I want is, along with the above result, to also get tabular values and I want to extract only the Vonmises stress column and dump that into a text file.</p>

<pre><code>     ELEMNT-ID GRID-ID FIB-DIS STRESSES IN ELEMNT COORD SYS PRINCIPAL STRESSES
                                Norm-X  Norm-Y  Shear-XY     Angle Major Minor Vonmises   
        1         2     45         234    4565    675         65     345   345   54345
                 43     32         444    3243    324         65     453   543   34223 
</code></pre>
