Skip to content

Instantly share code, notes, and snippets.

@azampagl
Created August 12, 2016 20:46
Show Gist options
  • Save azampagl/36a69b1bf8503764197dc9e24529448f to your computer and use it in GitHub Desktop.
Save azampagl/36a69b1bf8503764197dc9e24529448f to your computer and use it in GitHub Desktop.
data = [{'id': 1, 'value': "{name: 'Aaron', 'Coolness': 10}"}, {'id': 2, 'value': "{name: 'Fil', 'Coolness': 10}"}]
df = sqlContext.createDataFrame(data)
# print df.rdd.collectAsMap()
import json
with open('/tmp/myoutput.json', 'w') as outfile:
json.dump(df.rdd.collectAsMap(), outfile)
# display(dbutils.fs.ls("file:/tmp/myoutput.json"))
dbutils.fs.mkdirs("/FileStore/4thera")
dbutils.fs.cp("file:/tmp/myoutput.json", "/FileStore/4thera/myoutput.json")
# Go to https://community.cloud.databricks.com/files/4thera/myoutput.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment