scala split key, value by separator then add into one map


    var clearedLine = ""     var dict = collection.mutable.Map[String, String]()     val rdd =  BufferedSource.map(line=> ({           if (!line.endsWith(", ")) {             clearedLine = line+", "           } else{             clearedLine = line.trim           }       clearedLine.split(",")(0).trim->clearedLine.split(",")(1).trim       }       //,clearedLine.split(",")(1).trim->clearedLine.split(",")(0).trim     )       //dict +=clearedLine.split(",")(0).trim.replace(" TO ","->")     )      for ((k,v) <- rdd) printf("key: %s, value: %s\n", k, v) 

OUTPUT:

key: EQU EB.AR.DESCRIPT TO 1, value: EB.AR.ASSET.CLASS TO 2 key: EB.AR.CURRENCY TO 3, value: EB.AR.ORIGINAL.VALUE TO 4 

I want to split By ‘ TO ‘ then prouduce the single dict key->value

   key: 1,  value: EQU EB.AR.DESCRIPT ,     key: 2   value: EB.AR.ASSET.CLASS,     key: 3,  value: EB.AR.CURRENCY ,       key: 4,  value: EB.AR.ORIGINAL.VALUE