-1

How can I write my pyspark RDD's contents into a csv file. I am using the below code but it is not working :

df.saveAsTextFile(r'D:\asdf.csv')
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
Ishan
  • 996
  • 3
  • 13
  • 34
  • 1
    Possible duplicate of [How to write the resulting RDD to a csv file in Spark python](http://stackoverflow.com/questions/31898964/how-to-write-the-resulting-rdd-to-a-csv-file-in-spark-python) –  Aug 11 '16 at 22:03

1 Answers1

0

Use the spark-csv package from Databricks: https://github.com/databricks/spark-csv

df.save('df.csv', 'com.databricks.spark.csv')
Matt Frei
  • 379
  • 1
  • 4
  • 13