It is not clear what exactly you are up to,But There is TI function Dimix to check for the element exists.Please describe in detail with the actual data what you are trying to achieve.
Indeed, this sounds like somthing that could be solved with a fairly straight forward TI as the compiled (if thats the right word) data files will be expressed fully in TM1 when TM1 is loaded, which would then allow you to use a TI, the data files are seperated and not always readable.
The only times I have gone into the data files is to change a time of a Chore (GMT bug) or to use a program without the API to go into the .cub files and get all the dimensions, which was not pretty.