Have data in CSV file below is the format. Want to split JSON from Desc
column and create a new column with key.Using spark 2 with Scala.
+------+------------+----------------------------------+
| id | Category | Desc |
+------+------------+----------------------------------+
| 201 | MIS20 | { "Total": 200,"Defective": 21 } |
+------+-----------------------------------------------+
| 202 | MIS30 | { "Total": 740,"Defective": 58 } |
+------+-----------------------------------------------+
Output :
So the desired output would be:
+------+------------+---------+-------------+
| id | Category | Total | Defective |
+------+------------+---------+-------------+
| 201 | MIS20 | 200 | 21 |
+------+----------------------+-------------+
| 202 | MIS30 | 740 | 58 |
+------+------------------------------------+
Any help is highly appreciated.