I have found multiple results on how to save a Dataframe as CSV to disk on Databricks platforme.g. Spark Dataframe save as CSV How to save a spark DataFrame as csv on disk?
However, whenever I try to apply the answers to my situation it failed. Therefore, I am submitting my own question on the issue here.
I generate the following Dataframe with the following code:
df = spark.read.format(file_type) \
.option("inferSchema", infer_schema) \
.option("header", first_row_is_header) \
.option("sep", delimiter) \
.load(file_location)
display(df)
I would now like to save the above dataframe to disk.
I have tried the following:
filepath = "/FileStore/tables"
df.coalesce(1).write.option("header","true").option("sep",",").mode("overwrite").csv("filepath")
But I get the following error:
Can someone let me know where I'm going wrong?