2

I have a CSV file with a column of string dd-MMM-yyyy (e.g. 03-APR-2019), which I want to read as date format.

my code to read as below:

 spark.read
      .option("header", "true")
      .option("inferSchema", "true")
      .option("quote", "\"")
      .option("escape", "\"")
      .option("multiLine", "true")
      .option("dateFormat", "dd-MMM-yyyy")
      .csv(csvInPath)

However, after my code read the CSV file, the date still appears as String in my data frame.

anyone can advise? thanks

Fred
  • 3,365
  • 4
  • 36
  • 57
user2778168
  • 193
  • 9
  • Possible duplicate try this link:https://stackoverflow.com/questions/40878243/reading-csv-into-a-spark-dataframe-with-timestamp-and-date-types – Mahesh Gupta Mar 02 '20 at 05:38

0 Answers0