I have a JSON file that I'd like to convert to JSON Lines in spark scala. I was able to figure it out in Python by just using Pandas read_json method and then writing it with some special lines parameters passed in.
Say the original format is:
{
"A": "400",
"B": "100",
"C": "DEM",
"D": "USD",
"E": "80029898",
"F": "1.64110-",
"G": "0 "
},
{
"A": "400",
"B": "100",
"C": "USD",
"D": "DEM",
"E": "80029898",
"F": "1.64110 ",
"G": "0 ",
},
I'd like to write is as:
{"A":"400","B":"100","C":"DEM","D":"USD","E":"80029898","F":"1.64110-","G":"0"}
{"A":"400","B":"100","C":"USD","D":"DEM","E":"80029898","F":"1.64110 ","G":"0"}
Thanks so much and have a great day!
[...]?spark.read.json(), and written usingdf.write.json(). Refer this link for more info and to build on your case