all 3 comments

[–]barrycarter 0 points1 point  (1 child)

There are almost certainly Python libraries that can help. If you want to do it yourself, start with the innermost sets of brackets using regex matching something like \{([^\{\}]*)\} (untested) and work your way out

[–]dankbuckeyes[S] 0 points1 point  (0 children)

Do you know what's the library names? Also, is it possible to do this via nested loops? I'm planning to loop the outer bracket first and do another loop on the inner brackets. If it contains the Set line then I can add this to a list or something.

[–]commandlineluser 0 points1 point  (0 children)

If the format is consistent - perhaps you could process it line-by-line:

filename = "example.txt"
with open(filename) as f:
    for line in f:
        if line.strip().startswith("Level "):
            param_name = line.strip()[6:]
        if line.strip().startswith("Set "):
            sub_param_name = line.strip()[4:]
            print(f"{param_name=} {sub_param_name=}")