回 帖 发 新 帖 刷新版面

主题:脚本语言处理文件求助

Hi, everyone!
我是一个新手.我有一个文本文件需要处理,格式如下:
          
          9
 STEP:           1
 O      2.997698      0.657515      5.705156
 O      7.648357      2.016885      4.157144
 O      5.353186      4.312977      2.996694
 H      2.437575      0.801248      6.493850
 H      2.438063      0.205649      4.977124
 H      8.561802      1.698343      4.015077
 H      7.701950      2.974175      4.414931
 H      6.151766      4.605122      3.496463
 H      4.905160      5.144835      2.666462
          9
 STEP:           2
 O      2.998070      0.657184      5.705003
 O      7.648308      2.016865      4.156881
 O      4.235698      1.236548      2.356464
 H     10.077325      6.701806     10.337846
 H      9.102703      6.049980     11.385760
 H      6.843356      4.687864      5.714633
 H      8.132155      5.155059      4.905710
 H      1.102669      4.447547     10.074528
 H     -0.329879      4.543191     10.860287
         9
 STEP:           3
 O      2.998441      0.656845      5.704844
 O      7.648256      2.016843      4.156617
 O      5.353609      4.313509      2.996365
 H      6.574531      8.780670      4.719093
 H     10.078395      6.702674     10.337645
 H      9.101932      6.049531     11.386651
 H      6.843652      4.688109      5.714163
 H      8.131308      5.156092      4.904513
 H      1.103577      4.447183     10.073753
         9
 STEP:           4
 O      2.998811      0.656501      5.704679
 O      7.648203      2.016819      4.156352
 O      5.353821      4.313774      2.996202
 H     10.079432      6.703487     10.337454
 H      9.101175      6.049083     11.387511
 H      6.843941      4.688343      5.713701
 H      8.130503      5.157150      4.903301
 H      1.104461      4.446804     10.073007
 H     -0.332405      4.543696     10.861344
         9
 STEP:           5
 O      2.999179      0.656149      5.704507
 O      7.648147      2.016793      4.156086
 O      5.354033      4.314039      2.996039
 H     10.080435      6.704243     10.337272
 H      9.100436      6.048636     11.388340
 H      6.844221      4.688566      5.713249
 H      8.129741      5.158234      4.902074
 H      1.105321      4.446408     10.072295
 H     -0.333491      4.543930     10.861879
.
.
.
但我希望处理为下面的格式:(两个H原子价到前面O下面,成为水分子的构型,总共三个水分子,当然下面还有未写完,为了方便看)
         9
 STEP:           1
 O      2.997698      0.657515      5.705156
 H      2.437575      0.801248      6.493850
 H      2.438063      0.205649      4.977124
 O      7.648357      2.016885      4.157144
 H      8.561802      1.698343      4.015077
 H      7.701950      2.974175      4.414931
 O      5.353186      4.312977      2.996694
 H      6.151766      4.605122      3.496463
 H      4.905160      5.144835      2.666462
          9
 STEP:           2
 O      2.998070      0.657184      5.705003
 H     10.077325      6.701806     10.337846
 H      9.102703      6.049980     11.385760
 O      7.648308      2.016865      4.156881
 H      6.843356      4.687864      5.714633
 H      8.132155      5.155059      4.905710
 O      4.235698      1.236548      2.356464
 H      1.102669      4.447547     10.074528
 H     -0.329879      4.543191     10.860287
         9
 STEP:           3
 O      2.998441      0.656845      5.704844
 H      6.574531      8.780670      4.719093
 H     10.078395      6.702674     10.337645
 O      7.648256      2.016843      4.156617
 H      9.101932      6.049531     11.386651
 H      6.843652      4.688109      5.714163
 O      5.353609      4.313509      2.996365
 H      8.131308      5.156092      4.904513
 H      1.103577      4.447183     10.073753
         9
 STEP:           4
 O      2.998811      0.656501      5.704679
 H     10.079432      6.703487     10.337454
 H      9.101175      6.049083     11.387511
 O      7.648203      2.016819      4.156352
 H      6.843941      4.688343      5.713701
 H      8.130503      5.157150      4.903301
 O      5.353821      4.313774      2.996202
 H      1.104461      4.446804     10.073007
 H     -0.332405      4.543696     10.861344
         9
 STEP:           5
 O      2.999179      0.656149      5.704507
 H     10.080435      6.704243     10.337272
 H      9.100436      6.048636     11.388340
 O      7.648147      2.016793      4.156086
 H      6.844221      4.688566      5.713249
 H      8.129741      5.158234      4.902074
 O      5.354033      4.314039      2.996039
 H      1.105321      4.446408     10.072295
 H     -0.333491      4.543930     10.861879
.
.
.
有高手愿意解答吗,谢谢!
Best 
Yongping Zeng

回复列表 (共1个回复)

沙发

我已经自己解决,请求版主删掉该帖,谢谢!

我来回复

您尚未登录,请登录后再回复。点此登录或注册