I am trying to write a VBScript which will read a text file and build a dictionary which contains lists. Let me explain with an example:
The input file would be a simple text file of the sort:
Male,Peter
Male,Chris
Male,Stewie
Male,Brian
Female,Lois
Female,Meg
When I run my script, I would like a dictionary with the first column as the key, and the second column as the values
{'Male':['Peter,Chris,Stewie,Brian']}
{'Female':['Lois,Meg']}
The lack of dynamic arrays or lists in VBScript is making this a real pain. Any suggestion how I might tackle this?
Cheers
Just to say, I’m not compete with posted answers for repo-point 😉
If you can convert my post to comment, feel free to do that.
I like Ansgar’s idea (+1) as it based on single Dictionary and that seems to me quite enough to get back easy what is stored inside.
The need of .Exists may come in use in 2 cases – (a) if we don’t know how many genders we have, and (b) if we don’t know how they looks like (pronunciation). The rest is similar to Ansgar’s idea.