I have created the following case class:
case class Data(ads:Option[Ads])
case class Ads(subject: Option[String]
, body:Option[String]
, price:Option[Int]
, location:Option[Location]
, attribut:Option[Seq[Attribut]]
)
case class Location(city:Option[String]
, zipcode:Option[String])
case class Attribut(key_label:Option[String]
, value_label:Option[String]
)
And I parse a JSON format (part of a HTML) with play framework.
I finally obtain an Object Ads
JsSuccess(Ads(Some("Subject"), SOme("Body"), Some(Price), Some(Location(Some("City"), Some("Zipcode")), Some(Attribut("key_label", "value_label"))
I want to save this in a CSV file in the following way:
Subject Body Price City Zipcode Key_Label Value_Label
Play Playing games 532 Geneve 95 GEN Gen2
I convert the object into a List of Ads(Some("Subject"), Some("Body"), Some(Price), Some(Location(Some("City"), Some("Zipcode")), Some(Attribut("key_label", "value_label")
and convert this list into a DataFrame.
But I have only one column Value which contains all the elements of the object.
Value
(Some("Subject"), SOme("Body"), Some(Price), Some(Location(Some("City"), Some("Zipcode")), Some(Attribut("key_label", "value_label")
Has someone got an idea please ? I don't really understand how to link scala object with dataset and dataframe. Thank you for your help.