Seeking to number rows 1 through 4, and then repeat with a loop

Hello, eager to find a way to solve a problem with data stacked vertical. Luckily, the data is in a similar pattern, it’s repeating every 4 rows, and each row is a header. The data is stored vertically because it’s coming from web data (html). On the web, it’s nice tables, however we need it to be horizontal. I’m familiar with pivot, where I’m stuck is how to loop only 4 rows, label those 4 rows 1,2,3,4… then move to the next 4.

id, html
1124, Tom
1124, Supervisor
1124, N/A
1124, N/A
1124, Jeff
1124, CEO
1124, 5%
1124, TextInfo_Texty
1199, Jill
1199, Owner
1199, 2%
1199, RandomTextInfo
1199, Sally
1199, Co-owner
1199, 2%
1199, TextInfo51FakeData
3324, Ashley
3324, Field Rep
3324, 1%
3324, TextInfo
3324, Isabel
3324, Marketing
3324, 1%
3324, TextInfo

About; Id is a foreign key, Html is the final parsed data from a web parsing process.

How: Using python selenium to (Extract & Load) get HTML files, and KNIME is the ETL (Extract Transform Load) prototyping tool, which connects to the HTML files in a directory.

Goal: I’m eager to repeat 1,2,3,4 for every 4 values, and I feel this will enable me an easier path for the next node(s) which will pivot everything into a normalized table.

Thanks everyone for the help/patience. Excited to see how you solve the problem.

Best regards,
Tyler

Ah ha, Chunk loop

Chunking loop start, each iteration processes another (consecutive) chunk of rows. The chunking can be set as either a fixed number of chunks (which is equal to the number of iterations) or a fixed number of rows per chunk/iteration.

Apologies for unnecessary post. I was trying everything but chunk loop, however chunk loops primary option in the UX is # of rows and it worked perfectly.

1 Like

Glad to see you’ve found the solution on your own @Tyler … I personally am not a fan of using loops when my number of rows are more than 5 figures. If you’re looking for an alternative, and your goal is to make a table like this:

Let me know.

Update: Oh never mind me. I re-read your second post, and I realize you’re looking to only label the rows to groups of 4. In that case, yes you’re absolutely right. Chunk Loop Node will negate the need to label the rows. You’re on the right track!

1 Like

Hi @Tyler

How about just a MathFormula node with:
floor($$ROWINDEX$$/4)
no loop needed :slight_smile:

gr. Hans

5 Likes

I’ve never used this node, excited to start. I believe this is the best answer as it will require less nodes. Appreciate your help.

1 Like

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