I have a path to a csv I'd like to read from. This csv includes three columns: "topic, key, value" I am using spark to read this file as a csv file. The file looks like the following(lookupFile.csv):
Topic,Key,Value fruit,aaa,apple fruit,bbb,orange animal,ccc,cat animal,ddd,dog //I'm reading the file as follows val lookup = SparkSession.read.option("delimeter", ",").option("header", "true").csv(lookupFile)
I'd like to take what I just read and return a map that has the following properties:
My hope is that I would get a map that looks like the following:
val result = Map("fruit" -> Map("aaa" -> "apple", "bbb" -> "orange"), "animal" -> Map("ccc" -> "cat", "ddd" -> "dog"))
Any ideas on how I can do this?