# Move head rows to a column

**URL:** <https://forum.knime.com/t/move-head-rows-to-a-column/45094>\
**Category:** KNIME Analytics Platform\
**Created:** [July 14, 2022, 1:29pm UTC](https://forum.knime.com/t/move-head-rows-to-a-column/45094 "2022-07-14T13:29:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![willy\_oracle](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/w/87869e/32.png) [@willy\_oracle](https://forum.knime.com/u/willy_oracle)\
**Post date:** [July 14, 2022, 1:29pm UTC](https://forum.knime.com/t/move-head-rows-to-a-column/45094/1 "2022-07-14T13:29:58Z")

</div>

Hi everybody.  
I’ve uploaded a csv that uses head rows, identified with specific value, to separate groups of row.  
I need to move the data from the head row to a new column, updating the value when a new group starts.  
Usually, with excel, I use a If instructions:

- if head row → take value from specific column
- if not head row → copy the value from this column, previous row  
Is it possible to obtain the same result in Knime?  
Thanks.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [July 14, 2022, 1:56pm UTC](https://forum.knime.com/t/move-head-rows-to-a-column/45094/2 "2022-07-14T13:56:10Z")

</div>

@willy_oracle typically you would mark all lines with a [Counter](https://kni.me/n/pVT_aAQrO1Jkt9cG). Then identify the ‘headers’ with a rule engine [IF Col1 LIKE “Head\*” =\> Counter] and keep that (starting) row in a separate column. Then you [fill the missings with the previous value](https://forum.knime.com/t/replace-placeholder-with-values-from-above/38602/4) so a block would emerge marking the data table:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/b/7b8efebca38ffc74b989bb3b846fc862531fc6d1.png)

So now you have the blocks marked an can use a [Table Row to Variable Loop Start – KNIME Community Hub](https://kni.me/n/q7loejCZ1HWH5hUr) or [Group Loop Start – KNIME Community Hub](https://kni.me/n/7a8fxq51Z1jrgXeM) to do something with the blocks (export them delete lines with missing values …).

> [@Filtering for a subset of data from a single table](https://forum.knime.com/t/filtering-for-a-subset-of-data-from-a-single-table/40107/9):
>
> @mvaldes I tried a few things and came up with this. But I fear if your Excel files do not al have this exact structure it can get more complicated. You might try to better identify the headers of the column if they might shift. Also the two screenshots you provided do not seem to be from the same file. So I think you will have to invest some more work. Key to the approach might be to mark the blocks you have by a rule filter (what would a start of a table block look like). In this …

> [@File Reader (Complex format) problem](https://forum.knime.com/t/file-reader-complex-format-problem/43962/4):
>
> @Dalmatino16 with the help of the Counter Generation you could give the lines numbers. Then you could use the [Rule engine](https://kni.me/n/zpGPAjDyExkFL2HB) to save the number of the line if a certain condition is met and store the line in a separate column (var\_start, var\_end). Then only keep those columns and use a [math node](https://kni.me/n/2fI5rIsFDCFPHc0R) to calculate the start and length. Then convert that into Flow Variables that you can then use to steer your File import. A somewhat similar example: You mabye could upload 3 or 4 examples with varyi…

> [@parsing hierarchical data](https://forum.knime.com/t/parsing-hierarchical-data/39997/4):
>
> @dvkumaraws2019 I gave it a try and hope I have covered all cases you mentioned.

–  
Edit: [KNIME and Excel — An Overview of What You Can Do | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/low-code-for-advanced-data-science/knime-and-excel-an-overview-of-what-you-can-do-c6d400319745)

---

<div class="post-metadata">

**Author:** ![willy\_oracle](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/w/87869e/32.png) [@willy\_oracle](https://forum.knime.com/u/willy_oracle)\
**Post date:** [July 14, 2022, 2:31pm UTC](https://forum.knime.com/t/move-head-rows-to-a-column/45094/3 "2022-07-14T14:31:37Z")

</div>

Thank you very much!!!  
It works.  
Probably the rule engine + fill with the previous value is sufficient.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [July 21, 2022, 2:32pm UTC](https://forum.knime.com/t/move-head-rows-to-a-column/45094/4 "2022-07-21T14:32:07Z")

</div>

Closed on July 21, 2022, 2:32pm UTC

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