I never use metaprogramming before. I imagined it makes a string to code? (it is probably wrong understanding at all) So I was thinking whether I can make use of it to process one of my text file. The file is like that
o = open("text.txt", "w") println(o, "A\t1; B\t\"abc\"; C\t\"efg\";") println(o, "A\t20; B\t\"ijkl\"; D\t\"mno\";") close(o)
‘;’ is used to defined each field. Each field includes a tab delineate of key and value pair. I would like to process it into a dictionary per line. For example line 1 to be the dictionary
Dict((“A”=>1, “B”=>“abc”, “C”=>“efg”))
I could do it by split and split. Since the raw string is already structured like dictionary definition, is it possible to directly proceed it into a dictionary? I know it is odd to do it like that. What’s the pros and cons of doing so?
Thank you very much!