我编写了如下代码,通过拆分提取所有表格数据。现在我想
通过删除表格中间的文本来提取最后一列(值)数据。
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)
表看起来像这样,后跟每列中的值。现在我想删除文本并提取值。
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