I have imported a text file containing 3 blocks of text. I want to be able to recognize a new block of text, which is always separated by two lines. Then join the text in the rows for that text block and add some text between each line.
Here is the Google Sheet, to make your own copy to have a play or edit. Just go to File -> Make a copy https://docs.google.com/spreadsheets/d/18dAX7P3gCnkUorkYOksyDUfFs_e34uqiwzNjupffo2A/copy
Here is my solution sheet. It's just one formula in cell B1. It's editable so you can poke around if you like. Take it for a test drive. The two row boundary between blocks of stuff is important for it's operation.
https://docs.google.com/spreadsheets/d/1sKcBuHwh4v0UECRtUX4mPfE6NOCPkyafhNYs7LSSa0A/edit?usp=sharing
Here's the solution:
=ARRAYFORMULA({"";IF({1;ARRAY_CONSTRAIN(A1:A,ROWS(A3:A),1)&ARRAY_CONSTRAIN(A2:A,ROWS(A3:A),1)=""},TRANSPOSE(SUBSTITUTE(TRIM(QUERY(IF((LOOKUP(ROW(A2:A),{2;FILTER(ROW(A3:A),ARRAY_CONSTRAIN(A1:A,ROWS(A3:A),1)&ARRAY_CONSTRAIN(A2:A,ROWS(A3:A),1)="")})=TRANSPOSE(LOOKUP(ROW(A2:A),{2;FILTER(ROW(A3:A),ARRAY_CONSTRAIN(A1:A,ROWS(A3:A),1)&ARRAY_CONSTRAIN(A2:A,ROWS(A3:A),1)="")})))*(A2:A<>""),A2:A&CHAR(10),),,9^99)),CHAR(10),"<break time="&CHAR(34)&"1000ms"&CHAR(34)&"/>")),)})
Hope it works.