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,550 points
116 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
• 67,660 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 in Big Data Hadoop by Omkar
• 67,660 points
1,569 views
0 votes
1 answer

How to import PIG data into HBase?

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

answered Feb 14 in Big Data Hadoop by Omkar
• 67,660 points
174 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 in Big Data Hadoop by Gitika
• 25,340 points
85 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 in Big Data Hadoop by Gitika
• 25,340 points
112 views
0 votes
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 in Apache Spark by Omkar
• 67,660 points
248 views
0 votes
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,710 points
3,303 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,710 points
391 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
• 67,660 points
718 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
• 67,660 points
628 views