Hi, I have a big data which has headers inside some rows. I wanted to subset the data per header with its value. My data looks something like this:
Header 1 | Column 2 | Column 3 | Column 4 |
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
Header 2 | Column 2 | Column 3 | Column 4 |
2 | 2 | 2 | 2 |
2 | 2 | 2 | 2 |
Header 3 | Column 2 | Column 3 | Column 4 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
I need to subset the data per Header, so I should have Header 2 with
Header 2 | Column 2 | Column 3 | Column 4 |
2 | 2 | 2 | 2 |
2 | 2 | 2 | 2 |
Header 3
Header 3 | Column 2 | Column 3 | Column 4 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
I tried creating a Flag column, assign 1 to each header then subset. But the result is incorrect as it subset 1 and blank with Subset 1 with all the headers. This is what I created:
CSV << New Column ("Flag", Numeric);
r = CSV << getRowsWhere( Contains( :Header 1, "Header " ));
Column(CSV, "Flag")[r] = 1;
Please help