abaqus分析之后,很多结果可以输出dat,msg,sta等文件中。可以用记事本、notpad++、editplus等软件打开编辑。
但是往往无法直接用excel、origin等软件打开,比如对结构特征值提取分析后,各阶模态、振型、参与因子等如下:
为了方便数据分析和绘图,可以将txt的数据转为csv格式。
读入一个文本文件(txt),这个文本文件中包含类似以下格式的数据,只处理数据部分,不处理 标题
:
# *********************
import re
f2 = open('Rn.csv', 'w')
with open('do.txt', 'r',encoding="utf-8") as f1:
ind_num=1 # 记录当前是第几行
for i in f1:
if ind_num<4: #跳过标题行,只处理输出的数据
ind_num=ind_num+1
continue
line = re.split('\s+', i) #将字符串i以全部空白字符为分割符,将其分割成一个字符列表
new_line = ','.join(line) # 将字符列表用','拼接成一个新字符串
new_line = new_line.strip(',') # 将新字符串尾部产生的','去掉
new_line=new_line+'\n'
print(new_line)
f2.write(new_line)
ind_num=ind_num+1 #进入下一行
f2.close()
输出到csv:
1,1.90976E+06,1381.9,219.94,1.0000,0.0000
2,7.35096E+07,8573.8,1364.6,1.0000,0.0000
3,7.45402E+07,8633.7,1374.1,1.0000,0.0000
4,2.87248E+08,16948.,2697.4,1.0000,0.0000
5,5.80709E+08,24098.,3835.3,1.0000,0.0000
6,2.21143E+09,47026.,7484.4,1.0000,0.0000
7,2.40486E+09,49039.,7804.9,1.0000,0.0000
8,2.63677E+09,51349.,8172.5,1.0000,0.0000
9,5.97603E+09,77305.,12303.,1.0000,0.0000
10,7.60634E+09,87214.,13881.,1.0000,0.0000
标签:1.0000,ABAQUS,09,0.0000,读入,二次开发,txt,csv
From: https://www.cnblogs.com/aksoam/p/17034417.html