I have following CSV
US;Americas
CA;Americas
FR;Europe
CH;Asia
...
I want to have Map of -> String, List, is it possible to achieve this via associate, or something else ?
So far I have this:
csv.split("\n").associate {
val (code, region) = it.split(";")
region to code
}
but this is just mapping the region to only one code, also tried
region to listOf(code)
expected result:
Americas -> US, CA, BR ...
Europe -> FR, IT, CH ...
Asia -> CH, JP, KR ...
;. If the country name has a;escaped, the simple solution will cut the field with the;.