主题:怎么把一个文件的数字抽取出来呢?
这个是我用ABAQUS处理得到的INP文件,我想用其中的单元数和节点数做后续分析(只要数字的哦!),该怎么读取呢?
得到的INP文件内容如下(部分数据以省略号代替):
*Heading
** Job name: 1B Model name: 1
*Preprint, echo=NO, model=NO, history=NO, contact=NO
**
** PARTS
**
*Part, name=PART-1-1
*Node
1, 3.60278225, 0., 40.5839424
2, 3.89955282, 0., 40.5839424
3, 3.89955282, 0., 80.5800018
4, 3.60278225, 0., 80.5800018
.
.
.
.
.
35680, 0.784501612, 9.96803856, 80.5800018
35681, 0., 11.3648901, 80.5800018
35682, 0., 12.6999998, 76.5179749
35683, 0.996430516, 12.6608505, 80.5800018
*Element, type=C3D20R
1, 177, 1471, 5251, 1415, 1, 134, 1387, 151, 9293, 9292, 9291, 9290, 9294, 9295, 9296,9297, 9299, 9298, 9300, 9301
2, 1471, 1472, 5252, 5251, 134, 135, 1388, 1387, 9304, 9303, 9302, 9292, 9305, 9306, 9307,9295, 9298, 9308, 9309, 9300
3, 1472, 182, 1443, 5252, 135, 2, 136, 1388, 9312, 9311, 9310, 9303, 9313, 9314, 9315,9306, 9308, 9316, 9317, 9309
.
.
.
.
.
7886, 5220, 5221, 9169, 9168, 1377, 1378, 5205, 5204, 35555, 35556, 35540, 35553, 35675, 35676, 35660,35673, 35674, 35677, 35662, 35659
7887, 5221, 5222, 9170, 9169, 1378, 1379, 5206, 5205, 35558, 35559, 35543, 35556, 35678, 35679, 35663,35676, 35677, 35680, 35665, 35662
7888, 5222, 1375, 5244, 9170, 1379, 133, 1380, 5206, 35561, 35562, 35546, 35559, 35681, 35682, 35666,35679, 35680, 35683, 35668, 35665
*Element, type=C3D20R
.
.
.
.
.
我希望得到的结果是这样的,就是把星号部分的内容和文字去掉:
第一,把单元数7888和节点数35683提取到第一行;
第二,把各个单元的应力值(3个应力/每单元)读出,把各节点的单元号及其对应的节点号(就是每个单元后面对应的20个值)读出来
也就是一得到以下这样的结果
35683,7888
1, 3.60278225, 0., 40.5839424
2, 3.89955282, 0., 40.5839424
3, 3.89955282, 0., 80.5800018
4, 3.60278225, 0., 80.5800018
.
.
.
.
.
35680, 0.784501612, 9.96803856, 80.5800018
35681, 0., 11.3648901, 80.5800018
35682, 0., 12.6999998, 76.5179749
35683, 0.996430516, 12.6608505, 80.5800018
1, 177, 1471, 5251, 1415, 1, 134, 1387, 151, 9293,
9292, 9291, 9290, 9294, 9295, 9296,9297, 9299, 9298, 9300, 9301
2, 1471, 1472, 5252, 5251, 134, 135, 1388, 1387, 9304,
9303, 9302, 9292, 9305, 9306, 9307,9295, 9298, 9308, 9309, 9300
3, 1472, 182, 1443, 5252, 135, 2, 136, 1388, 9312,
9311, 9310, 9303, 9313, 9314, 9315,9306, 9308, 9316, 9317, 9309
.
.
.
.
.
7886, 5220, 5221, 9169, 9168, 1377, 1378, 5205, 5204,
35555, 35556, 35540, 35553, 35675, 35676, 35660,35673, 35674, 35677, 35662, 35659
7887, 5221, 5222, 9170, 9169, 1378, 1379, 5206, 5205,
35558, 35559, 35543, 35556, 35678, 35679, 35663,35676, 35677, 35680, 35665, 35662
7888, 5222, 1375, 5244, 9170, 1379, 133, 1380, 5206,
35561, 35562, 35546, 35559, 35681, 35682, 35666,35679, 35680, 35683, 35668, 35665
得到的INP文件内容如下(部分数据以省略号代替):
*Heading
** Job name: 1B Model name: 1
*Preprint, echo=NO, model=NO, history=NO, contact=NO
**
** PARTS
**
*Part, name=PART-1-1
*Node
1, 3.60278225, 0., 40.5839424
2, 3.89955282, 0., 40.5839424
3, 3.89955282, 0., 80.5800018
4, 3.60278225, 0., 80.5800018
.
.
.
.
.
35680, 0.784501612, 9.96803856, 80.5800018
35681, 0., 11.3648901, 80.5800018
35682, 0., 12.6999998, 76.5179749
35683, 0.996430516, 12.6608505, 80.5800018
*Element, type=C3D20R
1, 177, 1471, 5251, 1415, 1, 134, 1387, 151, 9293, 9292, 9291, 9290, 9294, 9295, 9296,9297, 9299, 9298, 9300, 9301
2, 1471, 1472, 5252, 5251, 134, 135, 1388, 1387, 9304, 9303, 9302, 9292, 9305, 9306, 9307,9295, 9298, 9308, 9309, 9300
3, 1472, 182, 1443, 5252, 135, 2, 136, 1388, 9312, 9311, 9310, 9303, 9313, 9314, 9315,9306, 9308, 9316, 9317, 9309
.
.
.
.
.
7886, 5220, 5221, 9169, 9168, 1377, 1378, 5205, 5204, 35555, 35556, 35540, 35553, 35675, 35676, 35660,35673, 35674, 35677, 35662, 35659
7887, 5221, 5222, 9170, 9169, 1378, 1379, 5206, 5205, 35558, 35559, 35543, 35556, 35678, 35679, 35663,35676, 35677, 35680, 35665, 35662
7888, 5222, 1375, 5244, 9170, 1379, 133, 1380, 5206, 35561, 35562, 35546, 35559, 35681, 35682, 35666,35679, 35680, 35683, 35668, 35665
*Element, type=C3D20R
.
.
.
.
.
我希望得到的结果是这样的,就是把星号部分的内容和文字去掉:
第一,把单元数7888和节点数35683提取到第一行;
第二,把各个单元的应力值(3个应力/每单元)读出,把各节点的单元号及其对应的节点号(就是每个单元后面对应的20个值)读出来
也就是一得到以下这样的结果
35683,7888
1, 3.60278225, 0., 40.5839424
2, 3.89955282, 0., 40.5839424
3, 3.89955282, 0., 80.5800018
4, 3.60278225, 0., 80.5800018
.
.
.
.
.
35680, 0.784501612, 9.96803856, 80.5800018
35681, 0., 11.3648901, 80.5800018
35682, 0., 12.6999998, 76.5179749
35683, 0.996430516, 12.6608505, 80.5800018
1, 177, 1471, 5251, 1415, 1, 134, 1387, 151, 9293,
9292, 9291, 9290, 9294, 9295, 9296,9297, 9299, 9298, 9300, 9301
2, 1471, 1472, 5252, 5251, 134, 135, 1388, 1387, 9304,
9303, 9302, 9292, 9305, 9306, 9307,9295, 9298, 9308, 9309, 9300
3, 1472, 182, 1443, 5252, 135, 2, 136, 1388, 9312,
9311, 9310, 9303, 9313, 9314, 9315,9306, 9308, 9316, 9317, 9309
.
.
.
.
.
7886, 5220, 5221, 9169, 9168, 1377, 1378, 5205, 5204,
35555, 35556, 35540, 35553, 35675, 35676, 35660,35673, 35674, 35677, 35662, 35659
7887, 5221, 5222, 9170, 9169, 1378, 1379, 5206, 5205,
35558, 35559, 35543, 35556, 35678, 35679, 35663,35676, 35677, 35680, 35665, 35662
7888, 5222, 1375, 5244, 9170, 1379, 133, 1380, 5206,
35561, 35562, 35546, 35559, 35681, 35682, 35666,35679, 35680, 35683, 35668, 35665