Summing

Hello,

I have a code that comes from data, and in the data are associated “trains” that corresponds to each sample, and I have it counting all the samples in the same “train.” where It spits out a list such as:

We found64 Samples in Train13590168
We found64 Samples in Train13590185
We found64 Samples in Train13590747
We found64 Samples in Train13592075
We found64 Samples in Train13593563

etc. How do I create a routine that will tell me that I have 5 trains total (in this example). Any Ideas will be greatly appreciated. Thank You.

Cheers,
Edwin Baldelomar

I’m not sure what you want to do… If you want to count the number of lines containing the string “We found” and “Samples in Train” in a logfile, then a simple python script is enough. Or even a awk script (awk is on Linux). For python, you’d have something like:

f = file("logfile.txt") lines_with_text=0 for lines in f.readlines(): if(line.find("We found")>-1 and line.find("Samples in Train")>-1): lines_with_text+=1 print lines_with_text f.close()
But now, I’m not sure that this is what you want.

Thank you very much, I found a way but your idea was very helpful. Thank you so much.

Cheers,
Edwin Baldelomar