How to Group Spreadsheet Data by Column?

What is the best way to group spreadsheet data by column?
-OR-
How to group lists of arbitrary length in Column C under their heading in Column B, and then group Column B (also arbitrary lengths) lists under heading in Column A?

The solution I came up with (attached below) was to find nulls within my lists and then split the lists based on those null locations. Then carefully merge my split lists into the final structure.

As you can see, my way took very many nodes and seems overly complicated. What is the more efficient way to accomplish this?

Dynamo:
test.dyn (94.8 KB)

Data:
simple.xlsx (8.1 KB)

@Bren You can do something like this with Python to get the same result in 8 lines:

OUT = []
	
for row in IN[0]:
	if row[0] != None:
		OUT.append([[row[0]]])
	elif row[1] != None:
		OUT[-1].append([row[1],row[2]])
	else:
		OUT[-1][-1].append(row[2])
2 Likes

Stunningly simple!

Seems like the answer is always python… Guess I should start learning it.

1 Like

That’s clever. :rofl:

1 Like

@Bren Yes, Python is a beast! I would definitely recommend learning it.

@Nick_Boyts Yeah, couldn’t think of anything better in that moment :rofl:

1 Like