Jagan
Jagan

Reputation: 37

To Export Data from Spark Dataframe to CSV with User Defined Headers

I am reading a Hive table through Spark SQL and storing it in a Spark Dataframe. I am then exporting the data from the Data frame to CSV using coalesce command & it was successful. The only problem is I want to have the CSV Header in some understandable words but it is just the column names.

Is there a way to have my CSV header customized ?

Upvotes: 0

Views: 304

Answers (1)

pltc
pltc

Reputation: 6082

You can use df.withColumnRenamed('old', 'new') to rename columns before saving as CSV

Upvotes: 1

Related Questions