sdkn104/VBA-CSV

ParseCSVToDictionary

Closed this issue · 2 comments

Would it be possible to implement a function that returns a Dictionary where either the first column is used for the key or you can provide a column number that would be used as the key. Most of the time the data I am working with needs to be obtained using a key in my code so I end up creating a Collection/Array and using that to create the Dictionary so it would be nice to just get a Dictionary.

I am planning to implement ParseCSVToDictionary() and GetFieldDictionary() in the next release.

  csv = "key,value1,value2" & vbCrLf & "key1,v11,v12" ...
  Set dict = ParseCSVToDictionary(csv, keyColumn:=1, ...)
  MsgBox dict("key1")(2)   ---> v11
  field = GetFieldDictionary(csv)
  MsgBox dict("key1")(field("value2"))   ---> v12

ParseCSVToDictionary() has been released in v1.8