Created
April 26, 2019 04:55
-
-
Save connerxyz/3f44ecb78ef6122f94f77034f17d798a to your computer and use it in GitHub Desktop.
Write a Python dict to a single file in HDFS as JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You've got a Python dict in the driver program or shell | |
x = {"a":1,"b":2} | |
# You want to write it to a single HDFS file in JSON format | |
sc.parallelize([x]).toDF().coalesce(1).write.mode('append').json(/hdfs/path/...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
did you import anything to do this?