The raw data is basically an extract of a data dictionary.
The id column consists of both entity and attribute names.
If a row contains type as “G” and level1 as “G”, then it’s an Entity. and all the rows after that with type A and level2 with “M” meaning Mandatory are the attributes of that entity.
There may be several versions of the entity, so I would like to have only the version with the highest value. So for example - V03 is the valid entity.
So the output should be
Special Cases
There is some case, where an entity may be referred to another entity. This is referenced by level2 with the status as “G”. For example in CAR entity, EG entity is refered.