lundi 13 juin 2016

Iterate over some chunks of data starting with certain strings

I have worked on a program that could count the numbers of letters in a give data set, which start with >chrome followed by long chains of letters (a,b,c,d at random). The chunks of data exactly look like this:

("\n" shows space in the command line): ">chrome0001"\n"abcdbadbcbdabdcbdbbbbadbcbbdab>chrome0011" \n"bbbbadbcbabdbaaaadbcbddcdda>chrome0111"\n" .... (the total number of ">chrome" is 10)."

I want to count the numbers of letters that appear after each <chrome. And expected output should be like:

>>chrome0001 a:4 b:6 c:10 d: 11

I've been thinking about whether I could use \n and >chrome to get the program working but got stuck and studied many questions and answers on this website only to dig a hole deeper... can anybody help me with this, please?

Aucun commentaire:

Enregistrer un commentaire