How to convert Spark data into CSV?

0 votes
I have a Spark Sql. I wanted to know how to convert this to a csv data. Or maybe export the Spark sql into a csv file. How can I do this?
Nov 21, 2018 in Big Data Hadoop by digger
• 26,660 points
267 views

1 answer to this question.

0 votes

You can use this:

df.write
  .option("header", "true")
  .csv("<path to the directory>/out.csv")

You can also convert the whole data frame like this:

df.coalesce(1).write
    .format("com.databricks.spark.csv")
    .option("header", "true")
    .save("<path to the directory>/out.csv")
answered Nov 21, 2018 by Omkar
• 68,860 points

Related Questions In Big Data Hadoop

0 votes
1 answer

Spark.read.csv to create RDD into Dataframe

You can use a case class and ...READ MORE

answered Jan 21, 2019 in Big Data Hadoop by Omkar
• 68,860 points
1,903 views
0 votes
1 answer

How to import PIG data into HBase?

Follow the below steps to do it: # ...READ MORE

answered Feb 14, 2019 in Big Data Hadoop by Omkar
• 68,860 points
225 views
0 votes
1 answer

How to load data from HDFS into pig relation?

Hey, To load data from HDFS to pig ...READ MORE

answered May 7, 2019 in Big Data Hadoop by Gitika
• 25,440 points
192 views
0 votes
1 answer

How to load data from flat files into Hive?

Hey, You can load data from flat files ...READ MORE

answered Jun 26, 2019 in Big Data Hadoop by Gitika
• 25,440 points
272 views
+1 vote
1 answer
0 votes
1 answer

How to find the number of null contain in dataframe?

Hey there! You can use the select method of the ...READ MORE

answered May 3, 2019 in Apache Spark by Omkar
• 68,860 points
352 views
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,840 points
3,882 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,840 points
532 views
0 votes
1 answer

Hadoop Hive: How to convert multiple rows into comma separated values?

You can use the aggregator function collect_set to do ...READ MORE

answered Nov 14, 2018 in Big Data Hadoop by Omkar
• 68,860 points
951 views
0 votes
1 answer

Hadoop Hive Hbase: How to insert data into Hbase using Hive (JSON file)?

You can use the get_json_object function to parse the ...READ MORE

answered Nov 15, 2018 in Big Data Hadoop by Omkar
• 68,860 points
806 views