Databricks: How to Save Data Frames as CSV Files on Your Local Computer [towardsdatascience.com]
2. Save a data frame into CSV in FileStore
Using the above code on the notebook, I created a folder “df” and saved a data frame “Sample” into CSV. It is important to use coalesce(1) since it saves the data frame as a whole. At the end of this article, I will also demonstrate what happens when you don’t include coalesce(1) in the code.
Once you convert your data frame into CSV, go to your FileStore. You will see the folder and files you create. The “part-00000” is the CSV file I had to download on my local computer. I copied the path after /FileStore/ for step 3.
3. Download the CSV file on your local computer
In order to download the CSV file located in DBFS FileStore on your local computer, you will have to change the highlighted URL to the following:
As you noticed, the CSV path in bold (df/Sample.csv/part-00000-tid-8365188928461432060–63d7293d-3b02–43ff-b461-edd732f9e06e-4704-c000.csv) is from step 2. The number (3847738880082577) is from the original URL.
02:15 PM, 24 Sep 2021 by Iuri Sampaio Permalink