计数while循环分裂 [英] Counting in while loop splitting

查看:70
本文介绍了计数while循环分裂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有来自CHARMM程序的输出数据,我正在尝试解析。所以,我的输出程序中有三个变量HEAD,TAIL,WAT。我必须在每次计算出现次数并打印值。

我附加了程序和脚本文件的输出数据。

Hi All,
I have an output data from CHARMM program which I am trying to parse. So, there are three variable in my output program "HEAD, TAIL, WAT" on which I have to count the number of occurence each time and print the values.
I have attached the output data of the program and my script file.

展开 | 选择 | Wrap | 行号

推荐答案

正则表达式不是问题,它是逻辑。


如果您的数据与示例一致,您可以走这条路线,如果没有,那么我们需要做一个小改动。

The regex''s aren''t the problem, it''s the logic.

If you data is as consistent as the example, you could go this route, if not, then we''d need to make a minor change.

展开 | 选择 | Wrap | 行号


感谢Ron的回复,

我同意你的意见,并在我的脚本中尝试了你的建议。我的数据文件是常规的,我试图在每次程序遇到时打印HEAD,TAIL和WAT的值,如果是一组三个。因此,例如,最终处理输出如下:3列 - >第一个用于HEAD,第二个用于TAIL,第三个用于WAT,解析应该在三个一组中完成,例如当程序第一次匹配HEAD,TAIL和WAT时,它将是第1行并再次匹配然后行号2等等......,如果没有任何条目那么它应该在那里打印零。


我希望我清楚我在说上面的内容。

再次感谢。
Thanks Ron for the reply,
I agree with you and tried your suggestion in my script. My data file is regular and I am trying to print the values of HEAD, TAIL and WAT each time the program encounters if in a set of three. So for example, the final processing output be like this: 3 column -> 1st one for HEAD, 2nd one for TAIL and 3rd one for WAT and the parsing should be done in the group of three, so for example when the program matches HEAD, TAIL and WAT first time then it will be row 1 and again matches then row number 2 and so on..., if there is no entry for any then it should print zero there.

I hope i am clear what i am stating above.
Thanks once again.


我发布的代码将会这样做。我唯一遗漏的是2个printf语句(第一个在条件块内)并将初始值设置为0.


哪个部分你难以完成?


我看的越多,你的家庭作业看起来就越多,而不是你需要解决的现实问题。
The code I posted will do that. The only thing I left out was the 2 printf statements (the 1st one being inside a conditional block) and setting the initial values to 0.

Which part are you having trouble accomplishing?

The more I look at this, the more it looks like your homework assignment and not a real world problem that you need to solve.


这篇关于计数while循环分裂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆