Converse rows to columns (# of rows different per record)

Hi, I have a text file with school addresses and phone numbers sampled below. As you can see that the # of rows per record is not fixed. Otherwise I could use transpose node. Is there a way I can convert the rows to columns, having one row per record? Thank you!

Test School3
7639 W Dawl St
Tallahassee, FL 32304-3556
UNITED STATES

Test1 School
1234 Street Dr NE
Atlanta, GA 30322-0001
UNITED STATES
Phone: (999)999-9999(0)
Fax: (999)999-9999

Test2 Université
1234, ave de la Medecine
bureau 6745
Pavillon Ferdinand-Vandry
Quebec City, QC G1K 7P4
CANADA
Phone: 1232345432(0)
Fax: 1234327890

Welcome to the forum @rumanac.

Here’s an example that should get you started. I’m assuming that the empty lines that you show in your example data are present in your actual data.

image

  1. I used the line reader node to read the text file, making sure to go to the Advanced Settings tab and replace empty lines with a character that won’t appear in any of the text. In this case I used ‘|’.
    image

  2. The Transpose nodes turns this single column into a single row with multiple columns.

  3. The Column Combiner node combines all these columns into a single cell, with the comma as the delimiter.

  4. I then split this single cell into multiple columns using ‘,|,’ as the delimiter (from step 1)

  5. A final transpose gets you a row for every entry.

3 Likes

Thank you so much @elsamuel for the solution!

1 Like

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