Read lines of text into a single row and create new rows at key word

Hi …

I have a data file that I would like to compile into row. Is there a way that I can read the files lines into a row and then create a new row when the line begins with a specific term? In the example below, I need to start a new row every time is a row that starts with “Site:”

Site: Site 001
SUBURB: Suburb B
REGION: Reg002
GLA: 1234
Site: Site 001
SUBURB: Suburb C
REGION: Reg002
GLA: 12345
Site: Site 001
SUBURB: Suburb D
REGION: Reg001

GLA: 5643
Site: Site 001
SUBURB: Suburb D
REGION: Reg002
SUB-REGION: SR001
GLA: 123456
Site: Site 001
SUBURB: Suburb A
REGION: Reg003
GLA: 6547

To become rows:

|Site|Suburb|Region|SUB-REGION|GLA|
| Site 001| Suburb B| Reg002||1234|
| Site 001| Suburb C| Reg002||12345|
| Site 001| Suburb D| Reg001||5643|
| Site 001| Suburb D| Reg002|SR001|123456|
| Site 001| Suburb A| Reg003|| 6547|

Does anyone have an idea of how I could build a flow to convert a file like this into usable rows?

tC/.

Hi @TigerCole

I created this wf, it uses a GroupLoop. The Rule Engine is in place because the length of the new records can be different. KNIME_project2.knwf (50.1 KB)


gr, Hans

3 Likes

Hi @HansS

A really simple and elegant solution. Thank you…

tC/.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.