S
sunriselee
Hi all,
I want to parse some string lines into name value pairs, where the value
will be a list. Here are some sample lines:
line1 = """path {{data/tom} C:/user/john}"""
line2 = """books{{book music red} {book {math 1}
blue} {book {tom's book} green}}"""
For line1, the name is "path", the name-value should be the following
forms:
["path", ["data/tom", "C:/user/john"]]
For line 2, the name is "books", and the value should be a list in either
one of the following forms (either one is ok):
["books", [["book","music","red"],["book","math 1","blue"],["book", "tom's
book", "green"]]]
or
["books", ["book","music","red","book","math 1","blue","book", "tom's
book", "green"]]
Any ideas?
Many thanks!
I want to parse some string lines into name value pairs, where the value
will be a list. Here are some sample lines:
line1 = """path {{data/tom} C:/user/john}"""
line2 = """books{{book music red} {book {math 1}
blue} {book {tom's book} green}}"""
For line1, the name is "path", the name-value should be the following
forms:
["path", ["data/tom", "C:/user/john"]]
For line 2, the name is "books", and the value should be a list in either
one of the following forms (either one is ok):
["books", [["book","music","red"],["book","math 1","blue"],["book", "tom's
book", "green"]]]
or
["books", ["book","music","red","book","math 1","blue","book", "tom's
book", "green"]]
Any ideas?
Many thanks!