Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am stuck on a simple problem but I admit that by dint of searching, I cannot find the solution and it
drives crazy. I have a file which contains multiple lines with different levels and am looking to increment
an identifier at each level 1 and assign this identifier to all lines of the same level.
I thought of the "numeric sequence" but it increments me the value at each line of the level and not at the group.
Do you have any advice, I'm going nuts with this blocking problem for me.
Either an input file with the following lines:
LEVEL;NAME;VALUE
0;aaa;111
0;bbb;222
1;ccc;333
1;ddd;444
2;eee;555
2;fff;666
1;iii;999
1;jjj;000
2;kkk;123
2;lll;456
1;ooo;564
1;ppp;369
2;qqq;258
2;rrr;147
I am trying to define an incremented identifier which starts at 1 for example if level is equal to 1 and
to assign this identifier to all the lines which are of level 1 and to increment this identifier to +1
for the following level to 1. The result I am trying to get is the following:
LEVEL;NAME;VALUE;ID
0;aaa;111;
0;bbb;222;
1;ccc;333;1
1;ddd;444;1
2;eee;555;
2;fff;666;
1;iii;999;2
1;jjj;000;2
2;kkk;123;
2;lll;456;
1;ooo;564;3
1;ppp;369;3
2;qqq;258;
2;rrr;147;
I'm really stuck on this issue and I'm ashamed, and that's why I hand it over to the community.
Any help or advice will be greatly appreciated.
Thanking you in advance.
Hi,
After a few days of hindsight, I found the solution and I post the solution for those to whom it would be useful.
In fact, it suffices to break down the actions.
First, I filter my level 1 lines to keep only one while keeping the information and thus set up a counter on these lines.
This allows me to subsequently cross-reference the data between the initial data of my file and the identifiers of each level 1 according to each line concerned in my file. This allows me to obtain the desired result.
Sometimes taking a step back from a problem can help ...