1
ID,Score1,Score2,Total Score
user021,4/4,2/2,14.0/50.0

The above csv which generated using spark dataframe.

df.coalesce(1).write
      .mode("overwrite")
      .format("com.databricks.spark.csv")
      .option("header", "true")
      .save(url)

When we open that CSV in the excel sheet for Score1 and Score2 columns are converted to Date formate.

Is there Any configurations to keep both column Score1 and Score2 as string formate instead of date formate?

Things which I tried but no luck!

 df.coalesce(1).write
      .mode("overwrite")
      .format("com.databricks.spark.csv")
      .option("header", "true")
      .option("inferSchema", "false/true")
      .save(url)

I tried with inferSchema configuration but no luck in this.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Manju
  • 145
  • 2
  • 10
  • 1
    Possible duplicate of [Provide schema while reading csv file as a dataframe](https://stackoverflow.com/questions/39926411/provide-schema-while-reading-csv-file-as-a-dataframe) – Lamanus Sep 27 '19 at 11:14
  • All fields in the data frame are "string" data type only. – Manju Sep 27 '19 at 11:59
  • When the data type is string, How it got converted to date formate in the excel sheet? If I open CSV in the normal text editor I can see only `4/4`, not date formate. – Manju Sep 27 '19 at 12:02
  • Re:How it got converted to date formate in the excel sheet?. It is excel which is trying to interpret as it sees something like Date in that column. Once you open it in excel you can select that column and set the format as General or Text – Amit Sep 27 '19 at 14:56
  • 1
    This is an Excel question... – Marsellus Wallace Sep 27 '19 at 15:40
  • Is there any way to add double quotes to only numeric columns? – Manju Oct 09 '19 at 18:01

0 Answers0