Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using representational model, how do I get to the next level of the tree? #580

Open
dlmcshan opened this issue Feb 9, 2021 · 1 comment
Labels

Comments

@dlmcshan
Copy link

dlmcshan commented Feb 9, 2021

I am trying to read a large YAML file which contains the following structure:

  • CASE: ## should be "- CASE"
    ACCESSION:
    ...
    TXD_CASE:
    NICKNAME: ## next level/block of data but not a sequence (indent lost with formatting)
    ...
    SCRIPT_STRUCTS:
    - SCRIPT_STRUCT:
    RX:
    SUBSCRIPT_STRUCTS:
    - SUBSCRO{T_STRUCT:
    RY:
    ....

My issue is that using the representational model, I can get a list of the first level nodes under CASE but I don't know how to get to the the nodes underneath TXD_CASE: which is not followed with a sequence but if it were, then I wouldn't have a problem.
I believe that it must know about the substructure as it picks up other first level nodes listed after that TXD_CASE block.

I tried treating it as a sequence node but it complained that it couldn't cast the node into a Sequence node.
YamlSequenceNode txdItems = (YamlSequenceNode)mapping.Children[new YamlScalarNode("TXD_CASE")];

I am sure it must be trivial but I have not uncovered the trick!
Thanks, in advance, for your help.

@dlmcshan dlmcshan changed the title Using representational model, how to I get to the next level of the tree? Using representational model, how do I get to the next level of the tree? Feb 9, 2021
@dlmcshan
Copy link
Author

dlmcshan commented Feb 10, 2021

So, while I am pretty sure (but haven't consulted the YAML specifications) the YAML syntax is legit, I have a work around which is to modify the node following the TXD_CASE: (in my example) with "- NICKNAME" turning the TXD_CASE into a sequence node (even if it will be a sequence of one). I have about 50,000 such files so I will write a program to apply this fix to those files, assuming an immediate fix is not forthcoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants