How to download a file from Databricks filestore to a local machine?
Databricks provides an interface to upload a file from the local machine to the dbfs://FileStore file system. But for downloading the file from dbfs://Filestore, there is no direct method. But that can be achieved by a tweak.

Let's take a quick look at FileStore
%fsls /FileStore/tables/Some of the CSV files have more than 1Million rows, so its not possible to download them directly.

But here is a cool trick to download any file from Databricks filestore using displayHTML. Basically, it renders the HTML as output.
It is assumed the file is stored inside /FileStore/.
In our case, the file is under /FileStore/tables/Electricity_GRE.csv
/files/tables/Electricity_GRE.csvthe prefix /files is mandatory followed by the folder of the file you are trying to download.
%pythondisplayHTML("""<a href="/files/tables/Electricity_GRE.csv" download>Download CSV </a>""")
Clicking the Download CSV link (yes like web link), it downloads the file to your local machine.
Thank you Chris Grant for this handy tip.
Schedule a DDIChat Session in Coding, Software, and Mobile Development:
Apply to be a DDIChat Expert here. Work with DDI: https://datadriveninvestor.com/collaborate Subscribe to DDIntel here.






