cloudcalvin
8/17/2015 - 5:37 PM

Builld a JSON style mapping in scala using sequence of headers as keys and cvs.split(",") as key_values

Builld a JSON style mapping in scala using sequence of headers as keys and cvs.split(",") as key_values

//fiels are the array of data values
//column map is the headers 
val columnMap = Headers.column_name.zipWithIndex
val jsonMapping = (ListMap[String, Any]()/: columnMap) { (a, f) =>
  a + ( "\"" + f._1 + "\"" -> fields(f._2))
  fields.foreach(_ match => {case empty : null})