I have a dataframe with data as follows.
+---------------+-------+
|category |marks |
+---------------+-------+
|cricket |1.0 |
|tennis |1.0 |
|football |2.0 |
+---------------+-------+
I want to write the above dataframe into a csv file where file name will be created with current timestamp.
generatedDataFrame.write.mode ("append")
.format("com.databricks.spark.csv").option("delimiter", ";").save("./src/main/resources-"+LocalDateTime.now()+".csv")
But this code is not working properly. Giving the following error
java.io.IOException: Mkdirs failed to create file
Is there a better way to achieve this using scala and spark? Also even though I am trying to create the file with timestamp code is creating a directory with the timestamp and inside that directory a csv with data is created with a random name. how can I have the timestamp filename to these csv files instead of creating a directory?