Saving dataframe to json file with a specific name without creating partition files in Pyspark

Viewed 464

I have a dataframe which I want to write it as single json file with a specific name. But it is creating a partitioned file within the stated filename. How do I get this to write data directly to the filename I passed into my parameter? Below is the code in Python:

df_3.coalesce(1).write.format('json').mode('overwrite').save(filename)

Data is now written to mylocation.json/part-00000 and I just want this to be mylocation.json file.

I would appreciate any help.

0 Answers
Related