Created
August 17, 2015 17:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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