Skip to content

Instantly share code, notes, and snippets.

@cloudcalvin
Created August 17, 2015 17:37
Show Gist options
  • Select an option

  • Save cloudcalvin/37cec6bfa05d424a6878 to your computer and use it in GitHub Desktop.

Select an option

Save cloudcalvin/37cec6bfa05d424a6878 to your computer and use it in GitHub Desktop.
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})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment