I wrote the code as below its extracting all tabular data by splitting. Now i want to extract the last column(Values) data by removing Text in the middle of the table.

import re
f_read = open('filename','r')
f_write=open('filename','w')
str='CEN/4'
for line in f_read:    
    m=re.search(str,line)
    if m:
       for line in f_read:      # loop over the rows
            if not line.strip():
              continue
       line = line.split(' ',1)   # parse the columns
       print line
       f_write.writelines(line)

Table looks like this followed by values in each column.Now i want to remove the text and extract only the values of last column.

S T R E S S E S   I N   Q U A D R I L A T E R A L   E L E M E N T S   ( Q U A D 4 )        OPTION = BILIN  

  ELEMENT              FIBER            STRESSES IN ELEMENT COORD SYSTEM         PRINCIPAL STRESSES (ZERO   
                                                                                                     SHEAR)               
   ID      GRID-ID   DISTANCE        NORMAL-X      NORMAL-Y      SHEAR-XY      ANGLE        MAJOR                                                                                                                      MINOR       VON MISES 
    121      3423      342             4545          45435        4345           42353     3456456       67658          3435

Edited 3 Years Ago by pyTony: fixed formattingN

This article has been dead for over six months. Start a new discussion instead.