I have tried df.write.json("myNewJson")
which although does not throws any error or warning it simply doesn't create any file in the target. df.write.format("json").save("/MyDir/")
also seems to have the same problem. Am I missing some statement here?
Posting the exact code that worked for me for those who might stumble upon the same problem.. I was able to export a DataFrame schema to Json file using the below statements:
import java.io._
val a = df.schema.json
val writer = new PrintWriter(new File("/home/file"))
writer.write(a)
writer.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With